/* * @Author: mlchen 374826075@qq.com * @Date: 2026-07-22 15:43:30 * @LastEditors: mlchen 374826075@qq.com * @LastEditTime: 2026-11-19 17:00:39 * @FilePath: /kd-aiot-frontend-eom/vue.config.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ const CompressionWebpackPlugin = require('compression-webpack-plugin'); const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme'); const path = require('path'); const { name } = require('./package.json'); function resolve(dir) { return path.join(__dirname, dir); } module.exports = { publicPath: '/eos', lintOnSave: false, outputDir: 'dist', productionSourceMap: false, configureWebpack: { performance: { maxAssetSize: 2000000, maxEntrypointSize: 2000000 }, output: { // 把子应用打包成 umd 库格式 library: { type: 'umd', name: `${name}` }, chunkLoadingGlobal: `webpackJsonp_${name}` } }, devServer: { client: { overlay: { // 与 Vue CLI 默认值保持一致:编译警告不遮罩页面(第三方 vue-form-making 的 // "possible exports unknown" 警告会刷屏),只展示真正的编译错误 warnings: false, errors: true, // ResizeObserver 循环通知是浏览器/图表库的良性告警(ECharts 自适应时会触发), // webpack-dev-server 会把未捕获告警当作运行时错误弹出全屏遮罩,这里只过滤这一条 runtimeErrors: (error) => { const message = (error && error.message) || ''; return !/ResizeObserver loop (completed with undelivered notifications|limit exceeded)/.test( message ); } } }, headers: { // 允许跨域访问子应用页面 'Access-Control-Allow-Origin': '*' }, // 代理跨域的配置 proxy: { // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求 '/api': { // target: 'http://192.168.1.251:18086', //开发 // target: 'http://localhost:18086', //开发 // 本地联调临时指向本机后端(2026-11-05,联调后还原) // target: 'http://192.168.1.251:18186', //测试 // target: 'http://192.168.1.15:18086',//罗 // target: 'http://192.168.1.144:18086',//付 // target: 'http://192.168.1.9:18086', //c target: 'https://aiot.zoomwin.com.cn:51001/api', changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域 pathRewrite: { '^/api': '' } } } }, chainWebpack(config) { config.plugins.delete('prefetch'); // set svg-sprite-loader // config.module.rule('svg').exclude.add(resolve('./src/icons')).end(); // config.module // .rule('icons') // .test(/\.svg$/) // .include.add(resolve('./src/icons')) // .end() // .use('svg-sprite-loader') // .loader('svg-sprite-loader') // .options({ // symbolId: 'icon-[name]' // }) // .end(); config.module.rule('svg').exclude.add(resolve('src/icons')).end(); config.module .rule('icons') .test(/\.svg$/) .include.add(resolve('src/icons')) .end() .use('svg-sprite-loader') .loader('svg-sprite-loader') .options({ symbolId: 'icon-[name]' }) .end(); if (process.env.NODE_ENV !== 'development') { // gzip 压缩 config.plugin('compressionPlugin').use( new CompressionWebpackPlugin({ test: /\.(js|css|html)$/, threshold: 10240 }) ); } }, css: { loaderOptions: { sass: { sassOptions: { outputStyle: 'expanded', importer: transformElementScss() } } } } };