webpack.dev.conf.js 1.2 KB

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