webpack.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require("path");
  2. const HtmlWebpackPlugin = require("html-webpack-plugin");
  3. module.exports = {
  4. mode: "development",
  5. // development 开发模式
  6. // none 无
  7. // production 生产模式
  8. // entry:"./src/aaa.js" 单个入口
  9. // entry:[
  10. // "./src/a1.js",
  11. // "./src/a2.js"
  12. // ],
  13. // entry:{
  14. // hello:"./src/a1.js",
  15. // say:"./src/a2.js"
  16. // },
  17. output: {
  18. // filename:"[name].js",
  19. // filename:"fileMode.js", //指定打包后的文件名称
  20. clean: true, //自动删除旧的打包文件 生成新的打包文件
  21. // path:path.resolve(__dirname,"dist") //指定打包后的文件
  22. },
  23. module: {
  24. rules: [
  25. {
  26. test: /\.css$/,
  27. // use: [
  28. // { loader: 'style-loader'},
  29. // { loader: 'css-loader'},
  30. // ]
  31. use: ["style-loader", "css-loader"],
  32. },
  33. {
  34. test: /\.(png|svg|jpg|jpeg|gif)$/i,
  35. type: "asset/resource",
  36. },
  37. {
  38. test: /\.m?js$/,
  39. exclude: /(node_modules|bower_components)/,
  40. use: {
  41. loader: "babel-loader",
  42. options: {
  43. presets: ["@babel/preset-env"],
  44. },
  45. },
  46. },
  47. ],
  48. },
  49. plugins: [new HtmlWebpackPlugin({
  50. // title: "打包工具webpack"
  51. // template:"./src/demo.html"
  52. })],
  53. devtool:"inline-source-map"
  54. };