webpack.dev.conf.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var utils = require('./utils')
  2. var webpack = require('webpack')
  3. var config = require('../config')
  4. var merge = require('webpack-merge')
  5. var baseWebpackConfig = require('./webpack.base.conf')
  6. var HtmlWebpackPlugin = require('html-webpack-plugin')
  7. var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
  8. //引入多页面支持
  9. var multipageHelper = require('./multipage-helper')
  10. // add hot-reload related code to entry chunks
  11. Object.keys(baseWebpackConfig.entry).forEach(function (name) {
  12. baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
  13. })
  14. module.exports = merge(baseWebpackConfig, {
  15. module: {
  16. rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
  17. },
  18. // cheap-module-eval-source-map is faster for development
  19. devtool: '#cheap-module-eval-source-map',
  20. plugins: [
  21. new webpack.DefinePlugin({
  22. 'process.env': config.dev.env
  23. }),
  24. // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
  25. new webpack.HotModuleReplacementPlugin(),
  26. new webpack.NoEmitOnErrorsPlugin(),
  27. // https://github.com/ampedandwired/html-webpack-plugin
  28. // new HtmlWebpackPlugin({
  29. // filename: 'index.html',
  30. // template: 'index.html',
  31. // inject: true
  32. // }),
  33. new FriendlyErrorsPlugin()
  34. ]
  35. })
  36. //添加Html模板集合
  37. Array.prototype.push.apply(module.exports.plugins,multipageHelper.getDevHtmlWebpackPluginList())