-
Notifications
You must be signed in to change notification settings - Fork 110
/
webpack.config.dev.js
101 lines (101 loc) · 3.47 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const pathLib = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const OpenBrowser = require('open-browser-webpack-plugin');
const ExtractText = require('extract-text-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const config = require('./config/config');
module.exports = {
entry: {
index: [
'babel-polyfill',
'react-hot-loader/patch',
'webpack-hot-middleware/client?path=http://localhost:8000/__webpack_hmr',
pathLib.resolve(__dirname,'frontWeb', 'index.js')
],
vendor: ['react','react-dom','react-router-dom','redux','react-redux','redux-saga','swipe-js-iso','react-swipe','react-addons-pure-render-mixin']
},
output: {
path: pathLib.resolve(__dirname, 'build'),
publicPath: "/",
filename: '[name].[hash:8].js'
},
devtool:'eval-source-map',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.css$/,
exclude: /node_modules/,
use:ExtractText.extract({
fallback: "style-loader",
use: [
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]-[local]-[hash:base64:5]',
importLoaders: 1
}
},
'postcss-loader'
]
})
},
{
test:/\.(png|jpg|gif|JPG|GIF|PNG|BMP|bmp|JPEG|jpeg)$/,
exclude:/node_modules/,
use:[
{
loader:'url-loader',
options: {
limit:8192
}
}
]
},
{
test: /\.(eot|woff|ttf|woff2|svg)$/,
use: 'url-loader'
}
]
},
plugins: [
new CleanPlugin(['build']),
new ProgressBarPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.DefinePlugin({
"progress.env.NODE_ENV":JSON.stringify('development')
}),
new HtmlWebpackPlugin({
title: "My app",
showErrors: true,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),//保证出错时页面不阻塞,且会在编译结束后报错
new ExtractText({
filename:'bundle.[hash].css',
disable:false,
allChunks:true
}),
new OpenBrowser({url:`http://${config.hotReloadHost}:${config.hotReloadPort}`}),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: "manifest"
})
],
resolve: {
extensions: ['.js', '.json', '.sass', '.scss', '.less', 'jsx']
}
};