暫無描述

webpack.dev.conf.js 1.3KB

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