This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
92 lines (91 loc) · 2.67 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 HtmlWebPackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: "file-loader",
options: {}
}
]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
},
{
// css-modules css is loaded with "modules: true"
test: /\.mod\.css$/,
// There are multiple possible webpack configurations which allow using
// css-modules
//
// The first one does not use postcss at all, it only loads
// css with "modules: true"
// There is no postcss.config.js, as there is no postcss at all.
// use: [
// "style-loader",
// {
// loader: "css-loader",
// options: {
// modules: true,
// localIdentName: "[path][name]__[local]--[hash:base64:5]"
// }
// }
// ]
//
// The second one uses css-loader to preprocess, and then uses
// css-loader to handle the modules. The related postcss.config.js:
// module.exports = { plugins: [/* some postcss plugins */] };
use: [
"style-loader",
{
loader: "css-loader",
// The query parameter importLoaders allows to configure how many
// loaders before css-loader should be applied to
// @imported resources.
options: { modules: true, importLoaders: 1 }
},
"postcss-loader"
]
//
// The third option is to use postcss-loader without css-loader
//
// When postcss-loader is used standalone (without css-loader) don't
// use @import in your CSS, since this can lead to quite bloated
// bundles.
//
// This is not supported by this plugin yet.
// use: ["style-loader", "postcss-loader"]
},
{
// regular, global css is loaded with "modules: false"
test: filename =>
filename.endsWith(".css") && !filename.endsWith(".mod.css"),
use: ["style-loader", "css-loader"]
}
]
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
}),
new CopyWebpackPlugin([{ from: "public" }])
]
};