webpack.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const path = require("path");
  2. const HtmlWebpack = require("html-webpack-plugin")
  3. // node写法
  4. module.exports = {
  5. mode: "production",
  6. // entry:'./src/a2.js'
  7. // entry:['./src/a2.js','./src/a3.js']
  8. // entry:{
  9. // hi:'./src/a2.js',
  10. // hello:'./src/a3.js'
  11. // },
  12. // entry:"./Conspicuous/bag.js",
  13. output: {
  14. // filename:'[name]-[id]-[hash].js',
  15. clean: true,
  16. // path:path.resolve(__dirname,'dist')
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.css$/i,
  22. use: ["style-loader", "css-loader"],
  23. },
  24. {
  25. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  26. type: "asset/resource",
  27. },
  28. {
  29. test: /\.m?js$/,
  30. exclude: /(node_modules|bower_components)/,
  31. use: {
  32. loader: 'babel-loader',
  33. options: {
  34. presets: ['@babel/preset-env'],
  35. },
  36. },
  37. }
  38. ],
  39. },
  40. plugins:[
  41. new HtmlWebpack({
  42. title:"哈哈哈哈",
  43. template:"./src/index.html"
  44. })
  45. ],
  46. //文件大小限制
  47. performance: {
  48. maxEntrypointSize: 50000000,
  49. maxAssetSize: 30000000,
  50. },
  51. devtool:"inline-source-map"
  52. };