forked from webpack-contrib/mini-css-extract-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
83 lines (78 loc) · 1.7 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
const yn = require("../helpers/yn");
const Self = require("../../");
const ENABLE_HMR =
typeof process.env.ENABLE_HMR !== "undefined"
? Boolean(process.env.ENABLE_HMR)
: true;
const ENABLE_ES_MODULE =
typeof process.env.ES_MODULE !== "undefined"
? Boolean(process.env.ES_MODULE)
: true;
const OLD_API =
typeof process.env.OLD_API !== "undefined" ? yn(process.env.OLD_API) : true;
console.log(OLD_API);
module.exports = {
mode: "development",
output: {
chunkFilename: "[name].chunk.js",
publicPath: "/dist/",
crossOriginLoading: "anonymous",
},
module: {
rules: [
{
test: /\.css$/,
exclude: [/\.module\.css$/i],
use: [
{
loader: Self.loader,
},
{
loader: "css-loader",
options: {
esModule: ENABLE_ES_MODULE,
},
},
],
},
{
test: /\.module\.css$/i,
use: [
{
loader: Self.loader,
options: {
esModule: ENABLE_ES_MODULE,
},
},
{
loader: "css-loader",
options: {
modules: true,
esModule: ENABLE_ES_MODULE,
},
},
],
},
],
},
plugins: [
new Self({
filename: "[name].css",
chunkFilename: "[name].chunk.css",
experimentalUseImportModule: OLD_API,
}),
],
devServer: {
hot: ENABLE_HMR,
static: {
directory: __dirname,
watch: {
// prevent page reload on source change so that we can test HMR
ignored: /src/,
},
},
headers: {
"Access-Control-Allow-Origin": "*",
},
},
};