Browse Source

feat: 添加线上环境删console插件`vite-plugin-remove-console`

xiaoxian521 3 years ago
parent
commit
5e1e9d3c5f
4 changed files with 11 additions and 1 deletions
  1. 1 0
      package.json
  2. 6 0
      pnpm-lock.yaml
  3. 3 0
      vite.config.ts
  4. 1 1
      windi.config.ts

+ 1 - 0
package.json

@@ -113,6 +113,7 @@
     "vite": "2.6.14",
     "vite-plugin-full-reload": "^1.0.0",
     "vite-plugin-mock": "^2.9.6",
+    "vite-plugin-remove-console": "^0.0.6",
     "vite-plugin-style-import": "^1.2.1",
     "vite-plugin-windicss": "^1.6.1",
     "vite-svg-loader": "^2.2.0",

+ 6 - 0
pnpm-lock.yaml

@@ -74,6 +74,7 @@ specifiers:
   vite: 2.6.14
   vite-plugin-full-reload: ^1.0.0
   vite-plugin-mock: ^2.9.6
+  vite-plugin-remove-console: ^0.0.6
   vite-plugin-style-import: ^1.2.1
   vite-plugin-windicss: ^1.6.1
   vite-svg-loader: ^2.2.0
@@ -176,6 +177,7 @@ devDependencies:
   vite: 2.6.14_sass@1.45.0
   vite-plugin-full-reload: 1.0.0
   vite-plugin-mock: 2.9.6_mockjs@1.1.0+vite@2.6.14
+  vite-plugin-remove-console: 0.0.6
   vite-plugin-style-import: 1.3.0_vite@2.6.14
   vite-plugin-windicss: 1.6.1_vite@2.6.14
   vite-svg-loader: 2.2.0
@@ -5577,6 +5579,10 @@ packages:
       - supports-color
     dev: true
 
+  /vite-plugin-remove-console/0.0.6:
+    resolution: {integrity: sha512-nwzYfkk320uO9sYBCql6rTE/07cjhffnHjayHXLdeDDQD6nGwmuqvBB1YWHlvIeboKr/caMdkpZpE7pM5kk2fw==}
+    dev: true
+
   /vite-plugin-style-import/1.3.0_vite@2.6.14:
     resolution: {integrity: sha512-R3bEQcdhPqL+5CZiMXs9RGKwbBtIHBJmh7ngND3sJjCYbkBe6DGEL6DWGBS7xTaqfH+1mXRfX8lEK0W3PjQSzA==}
     peerDependencies:

+ 3 - 0
vite.config.ts

@@ -9,6 +9,7 @@ import fullReload from "vite-plugin-full-reload";
 import { viteMockServe } from "vite-plugin-mock";
 import styleImport from "vite-plugin-style-import";
 import ElementPlus from "unplugin-element-plus/vite";
+import removeConsole from "vite-plugin-remove-console";
 import { UserConfigExport, ConfigEnv, loadEnv } from "vite";
 import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor";
 
@@ -85,6 +86,8 @@ export default ({ command, mode }: ConfigEnv): UserConfigExport => {
       // jsx、tsx语法支持
       vueJsx(),
       WindiCSS(),
+      // 线上环境删除console
+      removeConsole(),
       // 修改layout文件夹下的文件时自动重载浏览器 解决 https://github.com/xiaoxian521/vue-pure-admin/issues/170
       fullReload(["src/layout/**/*"]),
       // 自定义主题

+ 1 - 1
windi.config.ts

@@ -1,10 +1,10 @@
+// https://cn.windicss.org/ 中文文档
 import { defineConfig } from "windicss/helpers";
 import colors from "windicss/colors";
 import typography from "windicss/plugin/typography";
 
 export default defineConfig({
   darkMode: "class",
-  // https://windicss.org/posts/v30.html#attributify-mode
   attributify: true,
 
   plugins: [typography()],