-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.dev.config.js
82 lines (80 loc) · 1.93 KB
/
webpack.dev.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
const webpackMerge = require('webpack-merge');
const webpack = require('webpack');
const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
const ip = require('ip').address();
const baseConfig = require('./webpack/base');
const config = require('./webpack/config');
const defPath = config.defPath;
const APP_PATH = defPath.APP_PATH;
module.exports = webpackMerge(baseConfig(), {
devtool: 'cheap-module-source-map',
entry: {
app: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://' + ip + ':8090',
'webpack/hot/only-dev-server',
'./app/js/index.js'
],
vendor: config.vendor
},
output: {
path: defPath.DEV_PATH,
// 所有输出文件的目标路径
filename: 'js/bundle.js',
publicPath: '/',
chunkFilename: '[name].chunk.js'
},
// webpack 如何输出结果的相关选项
module: {
rules: [
{
test: /\.(scss|sass|css)$/,
include: APP_PATH,
use: [
'style-loader', 'css-loader', 'postcss-loader', 'sass-loader' + config.sassLoaderSuffix
]
}, {
test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif|mp4|webm)(\?\S*)?$/,
include: APP_PATH,
loader: 'url-loader?limit=8192&name=imgs/[name].[ext]'
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
new webpack.optimize.CommonsChunkPlugin({
names: [
'vendor', 'manifest'
],
filename: 'js/[name].js',
minChunks: Infinity
}),
new ChunkManifestPlugin({
filename: 'chunk-manifest.json',
manifestVariable: 'webpackManifest'
})
],
devServer: {
contentBase: defPath.DEV_PATH,
publicPath: '/',
historyApiFallback: true,
clientLogLevel: 'none',
host: ip,
port: 8090,
open: true,
hot: true,
inline: true,
compress: true,
stats: {
colors: true,
errors: true,
warnings: true,
modules: false,
chunks: false
}
}
})