-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
78 lines (71 loc) · 1.84 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var gulp = require('gulp')
var stylus = require('gulp-stylus')
var cleancss = require('gulp-clean-css')
var autoprefixer = require('autoprefixer-stylus')
var concat = require('gulp-concat')
// var babel = require('gulp-babel')
var rollup = require('gulp-rollup')
var babel = require('rollup-plugin-babel')
var resolve = require('rollup-plugin-node-resolve')
var commonjs = require('rollup-plugin-commonjs')
var sourcemaps = require('gulp-sourcemaps')
var rollupsourcemaps = require('rollup-plugin-sourcemaps')
var uglify = require('gulp-uglify')
var server = require('gulp-ss-server')
gulp.task('style', function () {
gulp
.src(['src/styles/index.styl'])
.pipe(stylus({
use: [autoprefixer({
browsers: [
'last 2 versions', 'ie 9'
],
cascade: false
})]
}))
// .pipe(cleancss())
.pipe(gulp.dest('build/styles/'))
})
gulp.task('assets', function () {
gulp.src('src/styles/images/*.*')
.pipe(gulp.dest('build/styles/images'))
})
gulp.task('script', function () {
gulp
.src(['src/**/*.js'])
.pipe(sourcemaps.init())
.pipe(rollup({
sourceMap: true,
entry: './src/index.js',
format: 'umd',
moduleName: 'ContextMenu',
plugins: [
resolve({
jsnext: true,
main: true,
browser: true
}),
commonjs(),
babel({
exclude: ['node_modules/**', 'bower_components/**']
}),
rollupsourcemaps()
]
}))
.pipe(concat('index.js'))
// .pipe(uglify())
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('build/'))
})
gulp.task('dev', function () {
gulp.run('script', 'style', 'assets')
gulp.watch(['src/styles/index.styl'], function () {
gulp.run('style')
})
gulp.watch(['src/**/*.js'], function () {
gulp.run('script')
})
server.run({
port: 3000
})
})