webpack.dev.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const merge = require('webpack-merge');
  4. const baseWpConfig = require('./webpack.base.config');
  5. baseWpConfig.entry.unshift('webpack-hot-middleware/client');
  6. const HtmlWebpackPlugin = require('html-webpack-plugin');
  7. const CopyWebpackPlugin = require('copy-webpack-plugin');
  8. const publicDir = path.resolve(__dirname, '../server/public');
  9. const clientDir = path.resolve(__dirname, '../client');
  10. module.exports = merge(baseWpConfig, {
  11. mode: 'development',
  12. devtool: "#inline-source-map",
  13. output: {
  14. path: `${publicDir}/app`,
  15. filename: 'bundle.js'
  16. },
  17. module: {
  18. rules: [
  19. {
  20. test: /\.css$/,
  21. use: [
  22. 'vue-style-loader',
  23. 'css-loader'
  24. ]
  25. },
  26. ]
  27. },
  28. plugins: [
  29. new webpack.HotModuleReplacementPlugin(),
  30. new webpack.NoEmitOnErrorsPlugin(),
  31. new HtmlWebpackPlugin({
  32. template: `${clientDir}/index.html.template`,
  33. filename: `${publicDir}/index.html`
  34. }),
  35. new CopyWebpackPlugin([{from: `${clientDir}/assets/*`, to: `${publicDir}/`, flatten: true}])
  36. ]
  37. });