-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·112 lines (91 loc) · 2.42 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
var gulp = require("gulp");
var plugin = require("gulp-load-plugins")();
var browserSync = require("browser-sync").create();
var pluginName = 'inumber';
gulp.task("js", function() {
return (
gulp
.src(["src/INumber.js"])
.pipe(plugin.sourcemaps.init())
.pipe(
plugin.babel({
presets: [
[ '@babel/env' ]
],
plugins: [
"@babel/plugin-transform-modules-umd"
],
}, )
)
.pipe(plugin.rename({
basename: pluginName
}))
.pipe(plugin.sourcemaps.write("../dest"))
.pipe(plugin.headerComment(`
License: <%= pkg.license %>
Description: <%= pkg.description %>
Author: <%= (pkg.author) %>
Homepage: <%= pkg.homepage %>
`))
.pipe(gulp.dest("./dest"))
);
});
gulp.task("js-minify", function() {
return (
gulp
.src(["dest/" + pluginName + ".js"])
.pipe(plugin.jsmin())
.pipe(plugin.rename({
suffix: '.min'
}))
.pipe(plugin.headerComment(`
License: <%= pkg.license %>
Description: <%= pkg.description %>
Author: <%= (pkg.author) %>
Homepage: <%= pkg.homepage %>
`))
.pipe(gulp.dest("./dest"))
);
});
gulp.task("css", function() {
return (
gulp
.src(["./demo/src/*.styl"])
.pipe(
plugin.stylus().on("error",
plugin.notify.onError("*** STYLUS ***: <%= error.message %>")
)
)
.pipe( plugin.autoprefixer({ remove: false, cascade: false }) )
.pipe(gulp.dest("./demo"))
);
});
gulp.task("pug", function () {
return gulp
.src(["./demo/src/*.pug"])
.pipe(
plugin.pug({ pretty: true })
)
.on("error", plugin.notify.onError("*** PUG ***: <%= error.message %>"))
.pipe(gulp.dest("./"))
});
gulp.task("watcher", function (done) {
browserSync.reload("/");
done();
});
// Watch
gulp.task("watch", function() {
browserSync.init({
server: { baseDir: "./" },
open: false
});
gulp.watch("src/*.js", gulp.series("js", "js-minify", "watcher"));
gulp.watch("demo/src/*.styl", gulp.series("css", "watcher"));
gulp.watch("demo/src/*.pug", gulp.series("pug", "watcher"));
});
gulp.task("build", gulp.series("css", "js", "js-minify", "pug"), function(done) {
done();
});
gulp.task("default", gulp.series("css", "js", "js-minify", "pug", "watch"), function(done) {
done();
})