-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.dev.conf.js
85 lines (81 loc) · 2.88 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
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
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
// var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
var MpvueVendorPlugin = require('webpack-mpvue-vendor-plugin')
// copy from ./webpack.prod.conf.js
var path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
// add hot-reload related code to entry chunks
// Object.keys(baseWebpackConfig.entry).forEach(function (name) {
// baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
// })
module.exports = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
extract: true
})
},
// cheap-module-eval-source-map is faster for development
// devtool: '#cheap-module-eval-source-map',
// devtool: '#source-map',
output: {
path: config.build.assetsRoot,
// filename: utils.assetsPath('[name].[chunkhash].js'),
// chunkFilename: utils.assetsPath('[id].[chunkhash].js')
filename: utils.assetsPath('[name].js'),
chunkFilename: utils.assetsPath('[id].js')
},
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// copy from ./webpack.prod.conf.js
// extract css into its own file
new ExtractTextPlugin({
// filename: utils.assetsPath('[name].[contenthash].css')
filename: utils.assetsPath(`[name].${config.dev.fileExt.style}`)
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common/vendor',
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf('node_modules') >= 0
) || count > 1
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common/manifest',
chunks: ['common/vendor']
}),
new MpvueVendorPlugin({
platform: process.env.PLATFORM
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
// new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
// new HtmlWebpackPlugin({
// filename: 'index.html',
// template: 'index.html',
// inject: true
// }),
new FriendlyErrorsPlugin()
]
})