Skip to content

Commit

Permalink
feat(webpack.base.config.js): 添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
knight174 committed Aug 17, 2023
1 parent 384e386 commit 43aee46
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions build/webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const { resolve } = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
// vue
const { VueLoaderPlugin } = require('vue-loader')
const { DefinePlugin } = require('webpack')
// css
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
// 打包优化
const TerserPlugin = require('terser-webpack-plugin')
// element plus 自动加载
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')

// __dirname: D:\my_reps\webpack5_vue3_starter\build

const commonConfig = {
entry: './src/main.ts',
output: {
Expand Down Expand Up @@ -93,18 +94,22 @@ const commonConfig = {
]
},
plugins: [
// 指定 html 模板
new HTMLWebpackPlugin({
template: './index.html',
favicon: resolve(__dirname, '../public/favicon.ico')
}),
// Vue 插件
new DefinePlugin({
__VUE_PROD_DEVTOOLS__: false,
__VUE_OPTIONS_API__: true
__VUE_PROD_DEVTOOLS__: false, // 禁用 Vue 生产环境下的开发工具
__VUE_OPTIONS_API__: true // 启用 vue2 option api
}),
new VueLoaderPlugin(),
new VueLoaderPlugin(), // 解析 .vue 单文件
// CSS 优化:生成独立的 CSS 文件
new MiniCssExtractPlugin({
filename: 'style/[name].[contenthash:6].css'
}),
// Element UI 优化
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Expand Down

0 comments on commit 43aee46

Please sign in to comment.