-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
executable file
·79 lines (74 loc) · 1.78 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
const gulp = require("gulp");
const webpackStream = require("webpack-stream");
const webpack = require("webpack");
function swallowError(error) {
// If you want details of the error in the console
console.log(error.toString());
this.emit("end");
}
gulp.task("js", () => gulp
.src("./src/js/index.js")
.pipe(
webpackStream({
mode: "production",
output: {
filename: "index.js",
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /(node_modules)/,
loader: "babel-loader",
query: {
presets: ["@babel/preset-env"],
},
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.svg$/,
use: [
{
loader: "file-loader",
},
],
},
{
test: /\.(otf|eot|ttf|woff|woff2)$/,
use: {
loader: "file-loader",
},
},
{
test: /\.(jpg|jpeg|gif|png)$/,
use: [
{
loader: "file-loader",
},
],
},
],
},
externals: ["tls", "net", "fs"],
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"jquery-ui": "jquery-ui",
"jquery-collapse": "jquery-collapse",
"jquery-lazy": "jquery-lazy",
}),
],
// devtool: 'source-map',
})
)
.on("error", swallowError)
.pipe(gulp.dest("assets/js")));
gulp.task("watch", () => {
gulp.watch("src/js/**/*.js", gulp.series("js"));
gulp.watch("layouts/**/*.html");
});
gulp.task("build", gulp.series("js"));