-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
95 lines (89 loc) · 1.86 KB
/
Copy pathwebpack.config.js
File metadata and controls
95 lines (89 loc) · 1.86 KB
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
93
94
95
const path = require("path");
const BabelMinifyPlugin = require("babel-minify-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
module.exports = env => {
const mode = env.mode;
let plugins = [
new MiniCssExtractPlugin({
filename: "[name].css"
}),
// enable this plugin only if you use images or fonts
new CopyPlugin({
patterns: [
{ from: "img", to: "img" } // -> enable this line only if you have images dir under 'src/img/'
// { from: 'fonts', to: 'fonts' }, // -> enable this line only if you have fonts dir under 'src/fonts/'
]
})
]
if (mode === 'production') {
plugins.push(new BabelMinifyPlugin(
{},
{
comments: false
}
))
}
return {
mode,
devtool: "souce-map",
context: path.resolve(__dirname, "src"),
entry: ["./scss/main.scss", "./js/main.js"],
output: {
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /.(scss|css)$/,
exclude: /node_modules/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
reloadAll: true
}
},
"css-loader",
"postcss-loader",
"sass-loader"
]
},
{
test: /\.(png|svg|jpg|gif|jpeg)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "img/",
publicPath: "img/"
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: "url-loader",
options: {
name: "[name].[ext]",
limit: 10000,
mimetype: "application/font-ttf",
outputPath: "fonts/",
publicPath: "fonts/"
}
}
]
}
]
},
plugins
}
};