webpack.config.js 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const path = require("path");
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. // 抛出
  4. module.exports = {
  5. mode: "production",
  6. entry: "./src/b.js",
  7. // entry:'./news.js',
  8. entry: ["./src/a.js", "./src/b.js"],
  9. // entry:{
  10. // hi:'./src/a.js',
  11. // hello:'./src/b.js'
  12. // }
  13. output: {
  14. // filename:'[name]-[id]-[hash].js',
  15. // path:path.resolve(__dirname,'dist'),
  16. clean: true,
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.css$/i,
  22. use: ["style-loader", "css-loader"],
  23. },
  24. {
  25. // v-if v-for优先级谁高 (v2/v3)
  26. // png|svg|jpg|jpeg|gif 区别
  27. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  28. type: "asset/resource",
  29. },
  30. {
  31. test: /\.m?js$/,
  32. exclude: /(node_modules|bower_components)/,
  33. use: {
  34. loader: "babel-loader",
  35. options: {
  36. presets: ["@babel/preset-env"],
  37. },
  38. },
  39. },
  40. ],
  41. },
  42. plugins: [new HtmlWebpackPlugin({title:"你好啊"})],
  43. };