/* eslint-disable @typescript-eslint/camelcase */ // gzip 压缩代码 const CompressionPlugin = require("compression-webpack-plugin"); // 打包分析 const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; // terser-webpack-plugin 可不引入, @vue/cli-service 中已经引入了terser-webpack-plugin // const TerserPlugin = require('terser-webpack-plugin') module.exports = { devServer: { open: true, proxy: { "/labsl": { target: "http://60.205.177.43:28888", changeOrigin: true, secure: false, }, "/meiku": { target: "http://60.205.177.43:28888", changeOrigin: true, secure: false, }, "/datacenter": { target: "http://60.205.177.43:28888", changeOrigin: true, secure: false, }, "/equip-component": { target: "http://60.205.177.43:28888", changeOrigin: true, secure: false, }, // 图片服务器 "/image-service": { target: "http://39.97.179.199:8888", changeOrigin: true, secure: false, pathRewrite: { "^/image-service": "/image-service/", }, }, }, // 关闭esline overlay: { warnings: false, errors: false, }, }, chainWebpack: (config) => { config.output.filename("static/js/[name].[hash].js").end(); config.output.chunkFilename("static/js/[name].[hash].js").end(); }, lintOnSave: false, publicPath: "/persagyPlan", // 打包名称 outputDir: "persagyPlan", // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录 assetsDir: "static", transpileDependencies: [ "@persagy-web", // 指定对第三方依赖包进行babel-polyfill处理 ], productionSourceMap: false, // CSS 相关选项 css: { // 将组件内的 CSS 提取到一个单独的 CSS 文件 (只用在生产环境中) extract: true, }, // 配置webpack configureWebpack: (config) => { // 生成环境,删除console.log和debugger if (process.env.VUE_Plan_RealEnv === "production") { config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true; //删除console config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true; //删除 debugger config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ["console.log"]; //删除 } const plugins = [ // 压缩代码 new CompressionPlugin({ test: /\.js$|\.html$|\.css$/, // 匹配文件名 threshold: 10240, // 对超过10k的数据压缩 deleteOriginalAssets: process.env.NODE_ENV === "production", // false 不删除源文件 true 删除源文件 }), ]; // 生产环境打包分析体积 命令 npm run build --report 或者 yarn build --report if (process.env.NODE_ENV === "production" && (process.env.npm_config_report || process.env.npm_config_argv.indexOf("--report") !== -1)) { plugins.push(new BundleAnalyzerPlugin()); } return { plugins, }; }, // chainWebpack:config =>{ // config.module.rule('svg-sprite') // .use('svgo-loader') // .loader('svgo-loader') // } };