webpack.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const path = require("path");
  2. const HtmlWebpack = require('html-webpack-plugin');
  3. const { devtools } = require("vue");
  4. // 抛出
  5. // export const a =10;
  6. module.exports = {
  7. mode: "production", //development
  8. // 入口:
  9. // 1.单文件
  10. // entry:"./src/a1.js",
  11. // 2.多文件
  12. // entry: ['./src/a1.js','./src/a2.js'],
  13. // entry:{
  14. // first:'./src/a1.js',
  15. // second:'./src/a2.js'
  16. // },
  17. // 输出
  18. output: {
  19. // 自动删除旧的打包文件 生成新的打包文件
  20. clean: true,
  21. // 指定打包后的文件名称
  22. // filename:"[name]-[id]-[hash].js",
  23. // filename:"happy.js",
  24. // 指定打包后的文件夹
  25. // path:path.resolve(__dirname,'dist')
  26. },
  27. // loader
  28. module:{
  29. rules:[
  30. {
  31. test:/\.css$/,
  32. use: ["style-loader","css-loader"]
  33. },
  34. {
  35. test:/\.(png|jpg|jpeg|gif)$/,
  36. type: 'asset/resource'
  37. },
  38. {
  39. test: /\.m?js$/,
  40. exclude: /(node_modules|bower_components)/,
  41. use: {
  42. loader: 'babel-loader',
  43. options: {
  44. presets: ['@babel/preset-env'],
  45. },
  46. },
  47. },
  48. ]
  49. },
  50. // 插件
  51. plugins:[new HtmlWebpack({
  52. title:"你好啊",
  53. template: "./src/demo.html"
  54. })],
  55. // // 映射源码
  56. devtool:"inline-source-map"
  57. };