-
Notifications
You must be signed in to change notification settings - Fork 536
/
Copy pathwebpack.dev.conf.js
57 lines (50 loc) · 1.42 KB
/
webpack.dev.conf.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
var webpack = require('webpack'),
config = require('./webpack.base.conf'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
BrowserSyncPlugin = require('browser-sync-webpack-plugin'),
// SOURCE_MAP = true; // 大多数情况下用不到
SOURCE_MAP = false;
config.output.filename = '[name].js';
config.output.chunkFilename = '[id].js';
config.devtool = SOURCE_MAP ? 'eval-source-map' : false;
// add hot-reload related code to entry chunk
config.entry.app = [
'eventsource-polyfill',
'webpack-hot-middleware/client?reload=true',
'webpack/hot/only-dev-server',
config.entry.app
];
config.output.publicPath = '/';
// 开发环境下直接内嵌 CSS 以支持热替换
config.module.loaders.push({
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
test: /\.scss$/,
loader: 'style!css!sass'
});
config.plugins.push(
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
filename: 'index.html',
template: config.commonPath.indexHTML,
chunksSortMode: 'none'
}),
new BrowserSyncPlugin({
host: '127.0.0.1',
port: 9090,
proxy: 'http://127.0.0.1:9000/',
logConnections: false,
notify: false
}, {
reload: false
})
);
module.exports = config;