-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.config.js
88 lines (79 loc) · 2.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
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
const path = require("path");
const webpack = require("webpack");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = (env, argv) => {
env = env || process.env;
const isProduction = argv.mode === "production";
const isDevelopment = !isProduction;
const config = {
entry: "./src/index.tsx",
output: {
hashFunction: "sha256",
filename: "[name].bundle.js",
chunkFilename: "[name].chunk.js",
path: path.join(__dirname, "dist"),
},
devtool: isDevelopment
? "source-map"
: undefined,
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"],
alias: {
"vscode": require.resolve("monaco-languageclient/lib/vscode-compatibility"),
"jquery": "jquery/dist/jquery.slim.js",
}
},
module: {
rules: [
{ test: /\.(gv|dot)$/, use: ["raw-loader"] },
{ test: /\.render\.js$/, use: ["file-loader"] },
{ test: /\.html$/, use: ["html-loader"] },
{ test: /\.tsx?$/, use: ["ts-loader"] },
{ test: /\.s?css$/, use: ["style-loader", "css-loader", "sass-loader"] },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader", exclude: [/node_modules/] },
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.ejs",
filename: "./index.html",
env: {
includeMatomo: isProduction && !!env["MATOMO_API_BASE"] && !!env["MATOMO_ENABLED"],
// Has to end with a trailing forward slash!
matomoApiBase: env["MATOMO_API_BASE"] ? env["MATOMO_API_BASE"].trim() : undefined,
},
minify: {
collapseWhitespace: isProduction,
}
}),
new MonacoWebpackPlugin({
languages: [],
}),
new CopyWebpackPlugin([
{ from: "assets" },
{ from: "CNAME" },
]),
new CleanWebpackPlugin(),
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version),
DEV: JSON.stringify(isDevelopment),
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Popper: ["popper.js", "default"],
}),
],
node: {
fs: "empty",
child_process: "empty",
net: "empty",
crypto: "empty",
}
};
return config;
};