admin-fe/build/webpack.dev.conf.js

47 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-04-18 07:09:13 +00:00
var utils = require('./utils')
var path = require('path')
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')
2017-11-01 07:48:30 +00:00
var dependencies = require('../package.json').dependencies
2017-04-18 07:09:13 +00:00
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
2017-08-07 08:11:10 +00:00
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
2017-04-18 07:09:13 +00:00
})
function resolveApp(relativePath) {
2017-08-07 08:11:10 +00:00
return path.resolve(relativePath);
2017-04-18 07:09:13 +00:00
}
module.exports = merge(baseWebpackConfig, {
2017-08-07 08:11:10 +00:00
module: {
2017-11-09 10:27:00 +00:00
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
2017-08-07 08:11:10 +00:00
},
// cheap-source-map is faster for development
devtool: '#cheap-source-map',
cache: true,
plugins: [
new webpack.DefinePlugin({
2017-11-01 07:48:30 +00:00
'process.env': config.dev.env,
'DEPENDENCIES': JSON.stringify(dependencies)
2017-08-07 08:11:10 +00:00
}),
// 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',
favicon: resolveApp('favicon.ico'),
inject: true,
path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory
}),
new FriendlyErrorsPlugin()
]
2017-04-18 07:09:13 +00:00
})
2017-08-07 08:11:10 +00:00