This repository was archived by the owner on Jan 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
executable file
·100 lines (90 loc) · 2.18 KB
/
Copy pathwebpack.dev.config.js
File metadata and controls
executable file
·100 lines (90 loc) · 2.18 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
96
97
98
99
100
const {merge} = require("webpack-merge");
const path = require("path");
const webpack = require("webpack");
const assetConfig = require("./config/assetConfig.json");
const commonConfig = require("./webpack.common.config.js");
const postCssConfig = require("./postcss.config.js");
const BASE_PATH = path.resolve(__dirname, "");
const DIST_PATH = `${BASE_PATH}/build`;
module.exports = function(env = {target: "local"}) {
const devConfig = {
mode: "development",
devtool: "cheap-module-source-map",
output: {
publicPath: assetConfig[env.target].staticHost + assetConfig[env.target].staticPath,
filename: "[name].bundle.js",
chunkFilename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\.scss$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 2
}
},
{
loader: "postcss-loader",
options: postCssConfig
},
"sass-loader"
]
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1
}
},
{
loader: "postcss-loader",
options: postCssConfig
}
]
},
{
test: /\.(jpe?g|png|csv|pdf)$/i,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]"
}
}
},
{
test: /\.(woff(2)?|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,
use: {
loader: "url-loader",
options: {
limit: "10000"
}
}
}
]
},
optimization: {
namedModules: true
},
devServer: {
contentBase: DIST_PATH,
compress: true,
port: 3000,
historyApiFallback: true,
hot: true
},
plugins: [
new webpack.DefinePlugin({
BUILD_TYPE: JSON.stringify("dev")
})
]
};
return merge(commonConfig(env), devConfig);
};