webpack.config.js 876 B

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