webpack.dev.conf.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // 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. function resolveApp(relativePath) {
  14. return path.resolve(relativePath);
  15. }
  16. module.exports = merge(baseWebpackConfig, {
  17. module: {
  18. rules: utils.styleLoaders({
  19. sourceMap: config.dev.cssSourceMap
  20. })
  21. },
  22. // cheap-source-map is faster for development
  23. devtool: '#cheap-source-map',
  24. cache: true,
  25. plugins: [
  26. new webpack.DefinePlugin({
  27. 'process.env': config.dev.env
  28. }),
  29. new webpack.ProvidePlugin({
  30. $: 'jquery',
  31. 'jQuery': 'jquery'
  32. }),
  33. // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
  34. new webpack.HotModuleReplacementPlugin(),
  35. new webpack.NoEmitOnErrorsPlugin(),
  36. // https://github.com/ampedandwired/html-webpack-plugin
  37. new HtmlWebpackPlugin({
  38. filename: 'index.html',
  39. template: 'index.html',
  40. favicon: resolveApp('favicon.ico'),
  41. inject: true,
  42. path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory
  43. }),
  44. new FriendlyErrorsPlugin()
  45. ]
  46. })