-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
58 lines (57 loc) · 1.59 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
const LodashModuleReplacementPlugin = require("lodash-webpack-plugin");
const path = require("path");
const plugins = [new LodashModuleReplacementPlugin()];
module.exports = (env, argv) => {
const config = {
entry: "./frontend/src/index.js",
output: {
path: path.resolve(__dirname, "./frontend/static/frontend/")
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".json"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
include: path.resolve(__dirname, "./frontend/src/"),
use: {
loader: "babel-loader"
}
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
include: path.resolve(__dirname, "./frontend/src/"),
use: {
loader: "babel-loader"
}
},
{
test: /\.svg$/,
include: [
path.resolve(__dirname, "./frontend/static/frontend/"),
path.resolve(__dirname, "./frontend/templates/frontend/")
],
use: [
{
loader: "@svgr/webpack",
// Always inline styles into svg attributes because <style> tags would violate our CSP
options: { svgoConfig: { plugins: [{ inlineStyles: { onlyMatchedOnce: false } }] } }
}
]
}
]
},
watchOptions: {
ignored: /node_modules/
},
plugins: plugins,
externals: { react: "React", "react-dom": "ReactDOM" }
};
if (argv.mode === "development") {
config.devtool = "eval-source-map";
}
return config;
};