- 执行 npm audit fix 自动修复 41 个漏洞中的大部分(babel、webpack、axios 等) - 在 package.json 中添加 overrides 强制升级无法自动修复的间接依赖: - postcss >= 8.4.31(修复 CVE in @vue/component-compiler-utils) - serialize-javascript >= 7.0.5(修复 XSS/RCE in copy-webpack-plugin) - webpack-dev-server >= 5.2.1(修复源码泄露漏洞) - 漏洞数从 41 降至 0 - vue.config.js 中为 mini-css-extract-plugin 添加 ignoreOrder: true, 消除 Element Plus 按需导入时不同路由 chunk CSS 顺序冲突的警告 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
const path = require('path')
|
||
const AutoImport = require('unplugin-auto-import/webpack')
|
||
const Components = require('unplugin-vue-components/webpack')
|
||
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
|
||
const { defineConfig } = require('@vue/cli-service')
|
||
const { DefinePlugin } = require('webpack')
|
||
const { execSync } = require('child_process')
|
||
|
||
const commitInfo = execSync('git show -s --format=%cs(%h)').toString().trim()
|
||
|
||
module.exports = defineConfig({
|
||
publicPath: './',
|
||
transpileDependencies: true,
|
||
productionSourceMap: false,
|
||
configureWebpack: {
|
||
resolve: {
|
||
alias: { '@': path.resolve(__dirname, './src') }
|
||
},
|
||
plugins: [
|
||
AutoImport({
|
||
resolvers: [ElementPlusResolver()],
|
||
}),
|
||
Components({
|
||
resolvers: [ElementPlusResolver()],
|
||
}),
|
||
new DefinePlugin({
|
||
'process.env.VERSION': `'${commitInfo}'`
|
||
})
|
||
]
|
||
},
|
||
chainWebpack: config => {
|
||
// fork-ts-checker-webpack-plugin v6 与 TypeScript 5 不兼容(无法覆写只读的 performance.mark)
|
||
// 类型检查改由 tsc --noEmit 承担
|
||
config.plugins.delete('fork-ts-checker')
|
||
|
||
// Element Plus 按需导入时,不同路由 chunk 的 CSS 导入顺序不一致,
|
||
// 但这不影响最终样式(specificity 规则优先),忽略该警告
|
||
config.plugin('extract-css').tap(args => {
|
||
args[0].ignoreOrder = true
|
||
return args
|
||
})
|
||
},
|
||
devServer: {
|
||
port: 8080,
|
||
proxy: {
|
||
'^/api': {
|
||
target: process.env.VUE_APP_PROXY_TARGET,
|
||
changeOrigin: true
|
||
}
|
||
}
|
||
}
|
||
})
|