diff --git a/electron-app/package.json b/electron-app/package.json index 4c97e63..8215c1a 100644 --- a/electron-app/package.json +++ b/electron-app/package.json @@ -4,7 +4,7 @@ "description": "", "main": "main.js", "scripts": { - "test": "electron ./" + "run-desktop": "electron ./" }, "author": "", "license": "ISC", diff --git a/source/.env b/source/.env new file mode 100644 index 0000000..e69de29 diff --git a/source/.env.development b/source/.env.development new file mode 100644 index 0000000..e69de29 diff --git a/source/.env.production b/source/.env.production new file mode 100644 index 0000000..e69de29 diff --git a/source/package.json b/source/package.json index 8729d5f..fcb123f 100644 --- a/source/package.json +++ b/source/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "lint": "vue-cli-service lint", - "build-watch": "vue-cli-service build --watch" + "build-dev": "vue-cli-service build --mode dev --watch", + "build-prod": "vue-cli-service build -mode prod", + "lint": "vue-cli-service lint" }, "dependencies": { "core-js": "^3.6.5", diff --git a/source/vue.config.js b/source/vue.config.js index e334c7c..de48ca4 100644 --- a/source/vue.config.js +++ b/source/vue.config.js @@ -1,5 +1,35 @@ const Copy = require("./plugins/copy"); const Path = require("path"); +const TerserPlugin = require("terser-webpack-plugin"); +console.log("***env: ", process.env.NODE_ENV); +let configureWebpack = {}; +switch (process.env.NODE_ENV) { + case "development": { + configureWebpack = { + mode: "development", + devtool: "#source-map", + }; + break; + } + case "production": { + configureWebpack = { + mode: "production", + optimization: { + minimizer: [ + new TerserPlugin({ + terserOptions: { + compress: { + drop_console: true, // 移除console + } + } + }) + ] + } + }; + break; + } +} + module.exports = { publicPath: "/", outputDir: "dist", @@ -27,8 +57,5 @@ module.exports = { } } }, - configureWebpack: { - mode: "development",// production - devtool: "#source-map", - } + configureWebpack, };