webpack.dev.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const webpack = require('webpack')
  2. const merge = require('webpack-merge')
  3. const commonConf = require('./webpack.common.js')
  4. const devConf = {
  5. mode: 'development',
  6. devtool: 'cheap-module-eval-source-map',
  7. output: {
  8. filename: 'js/[name]_[hash:5].js',
  9. },
  10. devServer: {
  11. contentBase: 'dist',
  12. host:'127.0.0.1',
  13. open: true,
  14. hot: true,
  15. overlay: true,
  16. proxy: {
  17. }
  18. },
  19. module: {
  20. rules: [
  21. {
  22. test: /(?<!\.module)\.(scss|css)$/,
  23. use: [
  24. 'style-loader',
  25. {
  26. loader: 'css-loader',
  27. options: {
  28. importLoaders: 2
  29. }
  30. },
  31. 'sass-loader',
  32. 'postcss-loader'
  33. ]
  34. },
  35. {
  36. test: /(?<=\.module)\.(scss|css)$/,
  37. use: [
  38. 'style-loader',
  39. {
  40. loader: 'css-loader',
  41. options: {
  42. importLoaders: 2,
  43. modules: true
  44. }
  45. },
  46. 'sass-loader',
  47. 'postcss-loader'
  48. ]
  49. }
  50. ]
  51. },
  52. plugins: [
  53. new webpack.HotModuleReplacementPlugin(),
  54. new webpack.DefinePlugin({
  55. DEV: JSON.stringify(true)
  56. })
  57. ]
  58. }
  59. module.exports = merge(commonConf, devConf)