webpack.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const HtmlWebpackPlugin = require('html-webpack-plugin');
  2. const path = require('path');
  3. // node写法
  4. module.exports = {
  5. mode: 'production',
  6. // entry: "./src/index.js",
  7. // entry: ['./src/a.js','./src/index.js']
  8. // entry: {
  9. // hi:'./src/a.js',
  10. // hello:'./src/index.js'
  11. // }
  12. output: {
  13. // filename: '[name]-[id]-[hash].js',
  14. // path: path.resolve(__dirname, 'dist'),
  15. clean: true,
  16. },
  17. module: {
  18. rules: [
  19. {
  20. test: /\.css$/i,
  21. use: ['style-loader', 'css-loader'],
  22. }, {
  23. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  24. type: 'asset/resource',
  25. },
  26. {
  27. test: /\.m?js$/,
  28. exclude: /(node_modules|bower_components)/,
  29. use: {
  30. loader: 'babel-loader',
  31. options: {
  32. presets: ['@babel/preset-env'],
  33. },
  34. },
  35. },
  36. ]
  37. },
  38. plugins: [
  39. new HtmlWebpackPlugin({
  40. template:'./src/index.html'
  41. })
  42. ],
  43. devtool:'inlin-source-map'
  44. }