webpack.config.js 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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:"./index.js",
  9. output:{
  10. filename:"bundle.js",
  11. path:path.resolve(__dirname,"./dist")
  12. },
  13. resolve: {
  14. alias: {
  15. vue: 'vue/dist/vue.esm-bundler.js' // 关键配置
  16. }
  17. },
  18. module:{
  19. rules:[{
  20. test:/\.vue$/,
  21. use:[
  22. { loader:"vue-loader" }
  23. ]
  24. },
  25. // 处理 .js 文件
  26. {
  27. test: /\.js$/,
  28. loader: 'babel-loader',
  29. exclude: /node_modules/
  30. }]
  31. },
  32. plugins:[
  33. new VueLoaderPlugin(),
  34. new CleanWebpackPlugin(),
  35. new HtmlWebpackPlugin({
  36. inject:'body',
  37. title:"webpack sample ",
  38. template:"./index.html"
  39. })
  40. ]
  41. }