-
Notifications
You must be signed in to change notification settings - Fork 138
/
webpack.config.js
51 lines (51 loc) · 1.27 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
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = ({ googleAnalytics, longTermCaching } = {}) => ({
entry: {
web: "./app/entry.js"
},
cache: {
type: "filesystem",
buildDependencies: {
config: [__filename]
}
},
resolve: {
modules: [path.resolve(__dirname, "web_modules"), "node_modules"]
},
output: {
publicPath: "",
filename: "[name].js",
chunkFilename: longTermCaching ? "[contenthash].js" : undefined
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, "node_modules/sigma"),
loader: "imports-loader",
options: { this: ">window" }
},
{ test: /\.pug$/, use: "pug-loader" },
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
{ test: /\.png$/, type: "asset" }
]
},
plugins: [
compiler => {
// Hack to make html-webpack-plugin work
compiler.hooks.thisCompilation.tap("webpack.config.js", compilation => {
compilation.fileTimestamps = new Map();
});
},
new HtmlWebpackPlugin({
template: "./app/index.html"
}),
googleAnalytics &&
new webpack.DefinePlugin({
GA_TRACKING_CODE: JSON.stringify("UA-46921629-1"),
GA_TRACKING_CONFIG: JSON.stringify("webpack.github.io")
})
].filter(Boolean)
});