Browse Source

修改配置文件

yunxing 4 years ago
parent
commit
87c562ec60
1 changed files with 28 additions and 28 deletions
  1. 28 28
      vue.config.js

+ 28 - 28
vue.config.js

@@ -1,37 +1,37 @@
 /* eslint-disable @typescript-eslint/camelcase */
 // gzip 压缩代码
-const CompressionPlugin = require('compression-webpack-plugin')
+const CompressionPlugin = require("compression-webpack-plugin");
 // 打包分析
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
+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:8080',
+            "/labsl": {
+                target: "http://60.205.177.43:8080",
                 changeOrigin: true,
                 secure: false,
             },
-            '/meiku': {
-                target: 'http://60.205.177.43:8080',
+            "/meiku": {
+                target: "http://60.205.177.43:8080",
                 changeOrigin: true,
                 secure: false,
             },
-            '/datacenter': {
-                target: 'http://60.205.177.43:8080',
+            "/datacenter": {
+                target: "http://60.205.177.43:8080",
                 changeOrigin: true,
                 secure: false,
             },
-            '/equip-componnet': {
-                target: 'http://60.205.177.43:8080',
+            "/equip-componnet": {
+                target: "http://60.205.177.43:8080",
                 changeOrigin: true,
                 secure: false,
             },
             // 图片服务器
-            '/image-service': {
-                target: 'http://adm.sagacloud.cn',
+            "/image-service": {
+                target: "http://adm.sagacloud.cn",
                 changeOrigin: true,
                 secure: false,
             },
@@ -43,17 +43,17 @@ module.exports = {
         },
     },
     chainWebpack: (config) => {
-        config.output.filename('static/js/[name].[hash].js').end()
-        config.output.chunkFilename('static/js/[name].[hash].js').end()
+        config.output.filename("static/js/[name].[hash].js").end();
+        config.output.chunkFilename("static/js/[name].[hash].js").end();
     },
     lintOnSave: false,
-    publicPath: '/persagyPlan',
+    publicPath: "/persagyPlan",
     // 打包名称
-    outputDir: 'persagyPlan',
+    outputDir: "persagyPlan",
     // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
-    assetsDir: 'static',
+    assetsDir: "static",
     transpileDependencies: [
-        '@persagy-web', // 指定对第三方依赖包进行babel-polyfill处理
+        "@persagy-web", // 指定对第三方依赖包进行babel-polyfill处理
     ],
     productionSourceMap: false,
     // CSS 相关选项
@@ -64,30 +64,30 @@ module.exports = {
     // 配置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'] //删除
+        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: true, // false 不删除源文件 true 删除源文件
+                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())
+        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')
     // }
-}
+};