webpack.dev.conf.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var config = require('../config')
  2. var webpack = require('webpack')
  3. var merge = require('webpack-merge')
  4. var utils = require('./utils')
  5. var baseWebpackConfig = require('./webpack.base.conf')
  6. var HtmlWebpackPlugin = require('html-webpack-plugin')
  7. // add hot-reload related code to entry chunks
  8. Object.keys(baseWebpackConfig.entry).forEach(function (name) {
  9. baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
  10. })
  11. module.exports = merge(baseWebpackConfig, {
  12. module: {
  13. loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
  14. },
  15. // eval-source-map is faster for development
  16. devtool: '#eval-source-map',
  17. plugins: [
  18. new webpack.DefinePlugin({
  19. 'process.env': config.dev.env,
  20. 'COMMIT_HASH': JSON.stringify('DEV'),
  21. 'DEV_OVERRIDES': JSON.stringify(config.dev.settings)
  22. }),
  23. // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
  24. new webpack.optimize.OccurenceOrderPlugin(),
  25. new webpack.HotModuleReplacementPlugin(),
  26. new webpack.NoErrorsPlugin(),
  27. // https://github.com/ampedandwired/html-webpack-plugin
  28. new HtmlWebpackPlugin({
  29. filename: 'index.html',
  30. template: 'index.html',
  31. inject: true
  32. })
  33. ]
  34. })