This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
92 lines (85 loc) · 1.9 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
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
const path = require("path");
const webpack = require("webpack");
const metadata = require("./manifest/metadata.json");
const TerserPlugin = require("terser-webpack-plugin");
const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
const JSConfig = {
mode: "production",
stats: "none",
output: {
pathinfo: false
},
plugins: [
new webpack.DefinePlugin({
disqusdata: JSON.stringify(metadata.disqus)
})
],
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: false,
terserOptions: {
output: {
comments: false
}
}
})
]
}
};
if (process.env.NODE_ENV !== "production")
JSConfig.plugins.push(new HardSourceWebpackPlugin());
const babelEnv = (envName) => ({
module: {
rules: [
{
test: /\.m?js$/,
include: path.resolve(__dirname, "assets"),
use: {
loader: "babel-loader?cacheDirectory",
options: {
cacheDirectory: false,
envName
}
}
}
]
}
});
const inline = {
...JSConfig,
...babelEnv("legacy"),
entry: {
Critical: "./assets/js/Critical.js"
},
output: {
path: path.resolve(__dirname, "./views/modules/virtual"),
filename: "[name].js"
}
};
const internal = {
...JSConfig,
...babelEnv("legacy"),
entry: {
Okitavera: "./assets/js/Okitavera.js",
"polyfills/ScrollBehaviour": "./assets/js/polyfills/ScrollBehaviour.js"
},
output: {
path: path.resolve(__dirname, `${metadata.site.output}/assets/js/`),
filename: "[name].js"
}
};
const mInternal = {
...JSConfig,
...babelEnv("modern"),
entry: {
Okitavera: "./assets/js/Okitavera.js"
},
output: {
path: path.resolve(__dirname, `${metadata.site.output}/assets/js/`),
filename: "[name].mjs"
}
};
module.exports = [inline, internal, mInternal];