webpack.dev.conf.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. var baseOption = {"project":"zhengHong"};
  10. // add hot-reload related code to entry chunks
  11. Object.keys(baseWebpackConfig(baseOption).entry).forEach(function (name) {
  12. baseWebpackConfig(baseOption).entry[name] = ['./build/dev-client'].concat(baseWebpackConfig(baseOption).entry[name])
  13. })
  14. module.exports = merge(baseWebpackConfig(baseOption), {
  15. module: {
  16. rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap,project:baseOption.project })
  17. },
  18. // cheap-module-eval-source-map is faster for development
  19. devtool: '#cheap-module-eval-source-map',
  20. devServer:{
  21. hot:true
  22. },
  23. plugins: [
  24. new webpack.DefinePlugin({
  25. 'process.env': config.dev.env,
  26. 'host.PROJECT':JSON.stringify(baseOption.project),
  27. 'host.MQTT':JSON.stringify(""),
  28. }),
  29. // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
  30. new webpack.HotModuleReplacementPlugin(),
  31. new webpack.NoEmitOnErrorsPlugin(),
  32. // https://github.com/ampedandwired/html-webpack-plugin
  33. new HtmlWebpackPlugin({
  34. filename: 'index.html',
  35. template: 'index.html',
  36. inject: true
  37. }),
  38. new FriendlyErrorsPlugin()
  39. ]
  40. })