-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (64 loc) · 2 KB
/
webpack.config.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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const shell = require("shelljs");
module.exports = {
mode: "production",
entry: "./src/main.js",
externals: {
moment: "moment"
},
output: {
path: __dirname,
filename: "main.js"
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
plugins: [
new HtmlWebpackPlugin({
base: {
target: "_top"
},
inject: false,
cache: false,
filename: "Sidebar.html",
template: "src/index.ejs"
}),
new MiniCssExtractPlugin({
filename: "styles.css"
}),
{
apply(compiler) {
compiler.hooks.emit.tap("Concept Compilation", function (compilation) {
// The compilation.deleteAsset method was not available for some reason,
// this behavior is copied from the following source
// https://github.com/webpack/webpack/blob/28e11c3f263f6303f701c4bebe483bd7e034f91b/lib/Compilation.js#L2868
delete compilation.assets["main.js"];
delete compilation.assets["styles.css"];
});
}
},
{
apply: compiler => {
if (process.env.AUTO_CLASP_PUSH) {
compiler.hooks.done.tap("Clasp Push", function () {
shell.exec(`clasp push`, {
silent: true
});
console.log(`Pushed to apps script at ${new Date().toLocaleTimeString()}`);
});
}
}
}
],
};