webpack.dev.conf.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const copyWebpackPlugin = require('copy-webpack-plugin')
  4. const htmlWebpackPlugin = require('html-webpack-plugin')
  5. module.exports = {
  6. entry: {
  7. env: './config/env.js'
  8. },
  9. output: {
  10. path: path.resolve(__dirname, 'dist'),
  11. filename: 'js/[name].js'
  12. },
  13. module: {
  14. rules: [{
  15. test: /\.css$/,
  16. use: [
  17. { loader: 'style-loader' },
  18. {
  19. loader: 'css-loader',
  20. options: { modules: true}
  21. }
  22. ]
  23. }]
  24. },
  25. plugins: [
  26. new htmlWebpackPlugin({
  27. filename: 'index.html',
  28. template: './src/index.html',
  29. inject: 'head'
  30. }),
  31. new copyWebpackPlugin([{
  32. from: path.resolve(__dirname, 'src'),
  33. to: path.resolve(__dirname, 'dist'),
  34. ignore: ["index.html", "js/env.js"]
  35. }]),
  36. new webpack.HotModuleReplacementPlugin()
  37. ],
  38. devServer: {
  39. clientLogLevel: 'warning',
  40. quiet: true,
  41. open: true,
  42. contentBase: path.join(__dirname, "dist"),
  43. port: 80,
  44. host: '127.0.0.1'
  45. }
  46. }