-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.dev.js
executable file
·80 lines (76 loc) · 2.48 KB
/
webpack.config.dev.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
const webpack = require("webpack")
const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const CopyWebpackPlugin = require("copy-webpack-plugin")
const devPath = path.resolve(__dirname, "dev")
const merge = require("webpack-merge")
const baseConfig = require("./webpack.config.dev.base")
// const WriteFilePlugin = require('write-file-webpack-plugin');
const HappyPack = require("happypack")
const happyThreadPool = HappyPack.ThreadPool({ size: require("os").cpus().length - 1 })
const devConfig = {
mode: "development",
output: {
path: devPath,
filename: "[name].min.js"
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin([
{ from: "src/assets", to: path.resolve(devPath, "assets"), force: true }
]),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("local"),
"BUILD_ENV": JSON.stringify("local")
}),
new webpack.ProvidePlugin({
$: "jquery"
}),
// new WriteFilePlugin({
// test: /\.html$/,
// useHashIndex: true
// }),
//用唯一的标识符id来代表当前的HappyPack是用来处理一类特定文件
new HappyPack({
id: "babel-application-js",
threadPool: happyThreadPool,
verbose: true,
loaders: ["babel-loader"],
}),
].concat(baseConfig.htmlArray),
devServer: {
contentBase: devPath,
hot: true,
port: 9100,
disableHostCheck: true,
stats: {
// 添加时间信息
timings: true,
modules: false,
// 添加资源信息
assets: false,
entrypoints: false,
assetsSort: "field",
// 添加构建日期和构建时间信息
builtAt: true,
cached: false,
cachedAssets: false,
children: false,
chunks: false,
chunkGroups: false,
chunkModules: false,
chunkOrigins: false,
performance: true,
errors: true,
warnings: true,
}
},
// devtool: "source-map"
devtool: "cheap-module-eval-source-map"
}
module.exports = merge(baseConfig.baseConfig, devConfig)