-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (66 loc) · 2.76 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
const gulp = require("gulp");
const exec = require("gulp-exec");
const uglify = require("gulp-uglify");
const fs = require("fs");
const path = require("path");
const SRC_DIR = path.resolve(__dirname, "src");
const DIST_DIR = path.resolve(__dirname, "dist");
// ---
const options = {
continueOnError: false, // default = false, true means don't emit error event
pipeStdout: false, // default = false, true means stdout is written to file.contents
customTemplatingThing: "test" // content passed to gutil.template()
};
const reportOptions = {
err: true, // default = true, false means don't write err
stderr: true, // default = true, false means don't write stderr
stdout: true // default = true, false means don't write stdout
};
gulp.task("build", () => {
return gulp
.src("./src/index.js")
.pipe(exec("npm run build", options))
.pipe(exec.reporter(reportOptions));
});
gulp.task("watch", () => {
gulp.watch([`${SRC_DIR}/**/*`], ["build"]);
});
// gulp.task("default", () => {
// gulp
// .src("src/index.js")
// .pipe(
// )
// // babel 一些奇怪的转化方式,需要通过 uglify 再转换一下
// .pipe(
// uglify({
// mangle: false,
// preserveComments: "all",
// compress: {
// sequences: false, // join consecutive statemets with the “comma operator”
// properties: false, // optimize property access: a["foo"] → a.foo
// // dead_code : true, // discard unreachable code
// // drop_debugger : true, // discard “debugger” statements
// // unsafe : false, // some unsafe optimizations (see below)
// // conditionals : true, // optimize if-s and conditional expressions
// comparisons: false, // optimize comparisons
// // evaluate : true, // evaluate constant expressions
// // booleans : true, // optimize boolean expressions
// // loops : true, // optimize loops
// unused: true, // drop unused variables/functions
// // hoist_funs : true, // hoist function declarations
// // hoist_vars : false, // hoist variable declarations
// if_return: false, // optimize if-s followed by return/continue
// join_vars: true // join var declarations
// // cascade : true, // try to cascade `right` into `left` in sequences
// // side_effects : true, // drop side-effect-free statements
// // warnings : true, // warn about potentially dangerous optimizations/code
// // global_defs : {} // global definitions
// },
// output: {
// beautify: true
// },
// banner: "/* eew */"
// })
// )
// .pipe(gulp.dest("dist"));
// });