forked from didi/mand-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.conf.js
74 lines (70 loc) · 2.36 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
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const poststylus = require('poststylus')
const pxtorem = require('postcss-pxtorem')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const WebpackBar = require('webpackbar')
// const DashBoardPlugin = require('webpack-dashboard/plugin')
const pkg = require('../../package.json')
// 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])
// })
const pxtoremConfig = pxtorem({ rootValue: 100, propWhiteList: [], minPixelValue: 2 })
const argv = require('yargs').argv
let entry = {
'index': ['./build/webpack/dev-client', process.env.MAND_MOBILE === 'bundle' ? './examples/main.bundle.js' : './examples/main.js']
}
if (argv.component) {
entry = {
'index': ['./build/webpack/dev-client', './examples/single-component-main.js']
}
}
module.exports = merge(baseWebpackConfig, {
entry,
output: {
path: config.dev.assetsRoot,
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: config.dev.assetsPublicPath
},
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-eval-source-map',
plugins: [
new WebpackBar({
name: 'mand-mobile'
}),
new webpack.DefinePlugin({
'process.env': config.dev.env,
'COMPONENT_NAME': `'${argv.component}'`,
'MAN_VERSION': `'${pkg.version}'`
}),
// https://github.com/seaneking/poststylus#webpack
new webpack.LoaderOptionsPlugin({
options: {
stylus: {
use: [poststylus(pxtoremConfig)]
}
}
}),
// 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: config.dev.index,
template: './examples/index.html',
inject: true
}),
new FriendlyErrorsPlugin({
quiet: true
})
]
})