-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (70 loc) · 2.16 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
const gulp = require('gulp');
// const watch = require('gulp-watch');
const babel = require("gulp-babel");
const rollup = require('gulp-rollup');
const replace = require('rollup-plugin-replace');
const gulpSequence = require('gulp-sequence');
const plumber = require("gulp-plumber");
const eslint = require('gulp-eslint');
// 开发环境
gulp.task('build-dev', () => {
// return watch('src/nodeuii/**/*.js', {
// ignoreInitial: false
// }, () => {
return gulp.src('src/nodeuii/**/*.js')
.pipe(plumber())
.pipe(babel({
babelrc: false,
plugins: [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"transform-es2015-modules-commonjs"]
// presets: ['@babel/env']
}))
.pipe(plumber())
.pipe(gulp.dest('dist'))
// })
});
// 上线环境
gulp.task('build-prod', () => {
return gulp.src('src/nodeuii/**/*.js')
.pipe(plumber())
.pipe(babel({
babelrc: false,
plugins: [["@babel/plugin-proposal-decorators", { "legacy": true }],"transform-es2015-modules-commonjs"],
// presets: ['@babel/env'],
ignore: ['./src/nodeuii/config/index.js'],
}))
.pipe(gulp.dest('prod'))
});
gulp.task('build-config', () => {
return gulp.src('src/nodeuii/**/*.js')
.pipe(plumber())
.pipe(rollup({
output: {
format: 'cjs'
},
input: 'src/nodeuii/config/index.js',
plugins: [
replace({
"process.env.NODE_ENV": JSON.stringify('production')
})
]
}))
.pipe(gulp.dest('dist'))
});
gulp.task('lint',()=>{
return gulp.src('src/nodeuii/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
})
let _task = ['build-dev'];
if (process.env.NODE_ENV == 'production') {
// _task = ['build-prod'];
_task = gulpSequence('build-prod', 'build-config')
}
if (process.env.NODE_ENV == 'lint') {
// _task = ['build-prod'];
_task = ['lint']
}
gulp.task('default', _task)