Files
energy_storage/web/vue.config.js

80 lines
1.8 KiB
JavaScript
Raw Normal View History

const { defineConfig } = require('@vue/cli-service')
const path = require('path')
2025-08-29 12:06:02 +08:00
module.exports = defineConfig({
transpileDependencies: true,
publicPath: '/',
2025-08-29 12:06:02 +08:00
// 输出文件目录
outputDir: 'dist',
2025-08-29 12:06:02 +08:00
// 静态资源目录
assetsDir: 'static',
2025-08-29 12:06:02 +08:00
devServer: {
hot: true,
compress: true,
allowedHosts: 'all',
2025-08-29 12:06:02 +08:00
headers: {
// 1. 允许开发环境跨域
'Access-Control-Allow-Origin': '*'
2025-08-29 12:06:02 +08:00
},
historyApiFallback: true,
open: false,
2025-08-29 12:06:02 +08:00
port: 8080,
client: {
overlay: {
runtimeErrors: (error) => {
const ignoreErrors = [
'ResizeObserver loop limit exceeded',
'ResizeObserver loop completed with undelivered notifications.'
]
2025-08-29 12:06:02 +08:00
if (ignoreErrors.includes(error.message)) {
return false
2025-08-29 12:06:02 +08:00
}
return true
}
}
}
2025-08-29 12:06:02 +08:00
},
css: {
loaderOptions: {
scss: {
additionalData: `
@use "~@/style/color.scss";
@use "~@/style/antd.scss";
` //在每个 .scss 文件顶部自动添加这行代码,无需手动导入
}
2025-08-29 12:06:02 +08:00
},
extract: {
filename: `css/.[contenthash:8].css`,
chunkFilename: `css/.[contenthash:8].chunk.css`
}
2025-08-29 12:06:02 +08:00
},
// webpack相关配置
2025-08-29 12:06:02 +08:00
configureWebpack: {
// 自定义打包入口
// 扩展 webpack 配置
plugins: [
// 添加插件
],
2025-08-29 12:06:02 +08:00
resolve: {
alias: {
'@': path.join(__dirname, 'src')
}
}
2025-08-29 12:06:02 +08:00
},
// 是否在开发环境下通过 eslint-loader 在每次保存时 lint 代码
lintOnSave: process.env.NODE_ENV !== 'production',
2025-08-29 12:06:02 +08:00
// 是否使用包含运行时编译器的 Vue 构建版本
runtimeCompiler: false,
// 生产环境的 source map
productionSourceMap: true,
// 第三方插件配置
pluginOptions: {
// ...
}
})