webpack.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const path=require('path');
  2. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  3. //const { HtmlWebpackPlugin } = require("html-webpack-plugin");
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. //const { VueLoaderPlugin } = require('vue-loader/dist/index');
  6. const { VueLoaderPlugin } = require('vue-loader');
  7. module.exports={
  8. entry:{
  9. index:"./index.js",
  10. },
  11. output:{
  12. filename:"bundle.js",
  13. path:path.resolve(__dirname,"./dist")
  14. },
  15. resolve: {
  16. alias: {
  17. vue: 'vue/dist/vue.esm-bundler.js' // 关键配置
  18. }
  19. },
  20. module:{
  21. rules:[
  22. {
  23. test:/\.css$/i,
  24. use:["style-loader","css-loader"]
  25. },
  26. {
  27. test:/\.vue$/,
  28. use:[
  29. { loader:"vue-loader" }
  30. ]
  31. },
  32. // 处理 .js 文件
  33. {
  34. test: /\.js$/,
  35. loader: 'babel-loader',
  36. exclude: /node_modules/
  37. }]
  38. },
  39. plugins:[
  40. new VueLoaderPlugin(),
  41. new CleanWebpackPlugin(),
  42. new HtmlWebpackPlugin({
  43. inject:'head',
  44. title:"index page ",
  45. template:"./index.html",
  46. filename:"index.html",
  47. chunks:['index'],
  48. }),
  49. ]
  50. }