-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
42 lines (37 loc) · 1.32 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
/**
* 开发环境的配置
*/
const webpack = require('webpack');
const config = require('./webpack.base.config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const fs = require('fs');
config.devtool = '#source-map'; // source-map
config.output.publicPath = '/dist/'; // 资源路径
config.output.filename = '[name].js'; // 入口js命名
config.output.chunkFilename = '[name].chunk.js'; // 路由js命名
config.plugins = (config.plugins || []).concat([
// 提取CSS
new ExtractTextPlugin({
filename: '[name].css',
allChunks : true
}),
// 提取第三方库(从不同的bundle中提取所有的公共模块,并且将他们加入公共bundle中)
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors'
}),
// 构建html文件
new HtmlWebpackPlugin({
filename: '../index.html',
template: './app/template/index.html',
inject: 'body'
})
]);
// 写入环境变量
fs.open('./app/config/env.js', 'w', function (err, fd) {
var buf = 'module.exports = "development";';
fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer){
return err;
});
});
module.exports = config;