diff --git a/build/default.config.js b/build/default.config.js
new file mode 100644
index 00000000..69a856d5
--- /dev/null
+++ b/build/default.config.js
@@ -0,0 +1,124 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
+/**
+ * @description electron默认打包配置
+ * @author shuxiaokai
+ */
+const path = require("path");
+
+module.exports = {
+ pages: {
+ index: {
+ entry: "src/renderer/main.ts",
+ template: "public/index.html",
+ },
+ },
+ //=====================================devserver====================================//
+ devServer: {
+ port: 9999,
+ },
+ //=====================================css相关配置====================================//
+ css: {
+ loaderOptions: {
+ css: {
+ // 这里的选项会传递给 css-loader
+ },
+ sass: {
+ prependData: `@import "@/scss/index.scss";`,
+ },
+ },
+ sourceMap: false,
+ },
+ //=====================================扩展webpack配置====================================//
+ configureWebpack: {
+ resolve: {
+ alias: {
+ "@": path.resolve(__dirname, "../src/renderer"),
+ "@@": path.resolve(__dirname, "../src"),
+ "~": path.resolve(__dirname, "../"),
+ },
+ },
+ target: "web",
+ },
+ pluginOptions: {
+ electronBuilder: {
+ // contextIsolation: false,
+ nodeIntegration: true, //参考https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html
+ extends: null,
+ externals: [
+ "vue",
+ "axios",
+ "vue-electron",
+ "vue-router",
+ "vuex",
+ "vuex-electron",
+ "element-ui",
+ "js-cookie",
+ "mockjs",
+ "nprogress",
+ "monaco-editor",
+ "vuedraggable",
+ "ali-oss",
+ "json5",
+ "echarts",
+ "brace",
+ "urllib",
+ "got",
+ "@koa/cors",
+ "form-data",
+ "proxy-agent",
+ "shelljs",
+ "ssh2",
+ "koa",
+ "internal-ip",
+ ],
+ mainProcessFile: "src/main/background.ts",
+ mainProcessWatch: ["src/main/background.ts"],
+ builderOptions: {
+ productName: "快乐摸鱼",
+ appId: "com.example.yourapp",
+ publish: [
+ {
+ provider: "generic",
+ url: "",
+ },
+ ],
+ nsis: {
+ oneClick: false, // 是否一键安装
+ allowToChangeInstallationDirectory: true, // 允许修改安装目录
+ },
+ mac: {
+ icon: "public/icons/icon.icns",
+ },
+ win: {
+ icon: "public/icons/icon.ico",
+ },
+ linux: {
+ icon: "public/icons",
+ },
+ },
+ //参考 https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1432
+ chainWebpackMainProcess: (config) => {
+ config.module
+ .rule("babel")
+ .before("ts")
+ .use("babel")
+ .loader("babel-loader")
+ .options({
+ presets: [
+ [
+ "@babel/preset-env",
+ { modules: false, targets: { electron: "6" } },
+ ],
+ ],
+ plugins: ["@babel/plugin-proposal-class-properties"],
+ });
+ },
+ },
+ },
+ //=====================================eslint配置====================================//
+ lintOnSave: "error", //未通过eslint 禁止代码提交
+ //=====================================打包上线配置====================================//
+ publicPath: "/",
+ outputDir: "dist", //输出文件类型
+ productionSourceMap: false, //打包时候js是否添加sourceMap
+};
diff --git a/build/html.config.js b/build/html.config.js
new file mode 100644
index 00000000..595a6571
--- /dev/null
+++ b/build/html.config.js
@@ -0,0 +1,71 @@
+/**
+ * @description 打包为单个文件
+ * @author shuxiaokai
+ */
+/* eslint-disable @typescript-eslint/no-var-requires */
+const path = require("path");
+const HtmlWebpackPlugin = require("html-webpack-plugin");
+const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
+
+module.exports = {
+ pages: {
+ index: {
+ entry: "src/renderer/pages/modules/apidoc/doc-view/main.ts",
+ template: "public/index.html",
+ },
+ },
+ devServer: {
+ port: 9999,
+ },
+ //=====================================css相关配置====================================//
+ css: {
+ loaderOptions: {
+ sass: {
+ prependData: `@import "@/scss/index.scss";`,
+ },
+ },
+ extract: false,
+ sourceMap: false,
+ },
+ //=====================================扩展webpack配置====================================//
+ configureWebpack: {
+ resolve: {
+ alias: {
+ "@": path.resolve(__dirname, "../src/renderer"),
+ "~": path.resolve(__dirname, "../"),
+ },
+ },
+ optimization: {
+ splitChunks: false, // makes there only be 1 js file - leftover from earlier attempts but doesn't hurt
+ },
+ plugins: [
+ new HtmlWebpackPlugin({
+ templateParameters: {
+ BASE_URL: "/",
+ },
+ filename: "index.html", // the output file name that will be created
+ template: "public/index.html", // this is important - a template file to use for insertion
+ inlineSource: ".(js|css|png|jpg|woff|woff2|ttf)$", // embed all javascript and css inline
+ }),
+ new HtmlWebpackInlineSourcePlugin(),
+ ],
+ },
+ chainWebpack: (webpackConfig) => {
+ const fontsRule = webpackConfig.module.rule("fonts");
+ // clear all existing loaders.
+ // if you don't do this, the loader below will be appended to
+ // existing loaders of the rule.
+ fontsRule.uses.clear();
+ webpackConfig.module
+ .rule("fonts")
+ .test(/\.(ttf|otf|eot|woff|woff2)$/)
+ .use("base64-inline-loader")
+ .loader("base64-inline-loader")
+ .end();
+ },
+ //=====================================eslint配置====================================//
+ lintOnSave: "error", //未通过eslint 禁止代码提交
+ //=====================================打包上线配置====================================//
+ productionSourceMap: true, //打包时候js是否添加sourceMap
+ publicPath: "/",
+};
diff --git a/build/share.config.js b/build/share.config.js
new file mode 100644
index 00000000..b0095bc1
--- /dev/null
+++ b/build/share.config.js
@@ -0,0 +1,124 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
+/**
+ * @description electron默认打包配置
+ * @author shuxiaokai
+ */
+const path = require("path");
+
+module.exports = {
+ pages: {
+ index: {
+ entry: "src/renderer/pages/modules/apidoc/doc-view/main.ts",
+ template: "public/index.html",
+ },
+ },
+ //=====================================devserver====================================//
+ devServer: {
+ port: 9999,
+ },
+ //=====================================css相关配置====================================//
+ css: {
+ loaderOptions: {
+ css: {
+ // 这里的选项会传递给 css-loader
+ },
+ sass: {
+ prependData: `@import "@/scss/index.scss";`,
+ },
+ },
+ sourceMap: false,
+ },
+ //=====================================扩展webpack配置====================================//
+ configureWebpack: {
+ resolve: {
+ alias: {
+ "@": path.resolve(__dirname, "../src/renderer"),
+ "@@": path.resolve(__dirname, "../src"),
+ "~": path.resolve(__dirname, "../"),
+ },
+ },
+ target: "web",
+ },
+ pluginOptions: {
+ electronBuilder: {
+ // contextIsolation: false,
+ nodeIntegration: true, //参考https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html
+ extends: null,
+ externals: [
+ "vue",
+ "axios",
+ "vue-electron",
+ "vue-router",
+ "vuex",
+ "vuex-electron",
+ "element-ui",
+ "js-cookie",
+ "mockjs",
+ "nprogress",
+ "monaco-editor",
+ "vuedraggable",
+ "ali-oss",
+ "json5",
+ "echarts",
+ "brace",
+ "urllib",
+ "got",
+ "@koa/cors",
+ "form-data",
+ "proxy-agent",
+ "shelljs",
+ "ssh2",
+ "koa",
+ "internal-ip",
+ ],
+ mainProcessFile: "src/main/background.ts",
+ mainProcessWatch: ["src/main/background.ts"],
+ builderOptions: {
+ productName: "快乐摸鱼",
+ appId: "com.example.yourapp",
+ publish: [
+ {
+ provider: "generic",
+ url: "",
+ },
+ ],
+ nsis: {
+ oneClick: false, // 是否一键安装
+ allowToChangeInstallationDirectory: true, // 允许修改安装目录
+ },
+ mac: {
+ icon: "public/icons/icon.icns",
+ },
+ win: {
+ icon: "public/icons/icon.ico",
+ },
+ linux: {
+ icon: "public/icons",
+ },
+ },
+ //参考 https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1432
+ chainWebpackMainProcess: (config) => {
+ config.module
+ .rule("babel")
+ .before("ts")
+ .use("babel")
+ .loader("babel-loader")
+ .options({
+ presets: [
+ [
+ "@babel/preset-env",
+ { modules: false, targets: { electron: "6" } },
+ ],
+ ],
+ plugins: ["@babel/plugin-proposal-class-properties"],
+ });
+ },
+ },
+ },
+ //=====================================eslint配置====================================//
+ lintOnSave: "error", //未通过eslint 禁止代码提交
+ //=====================================打包上线配置====================================//
+ publicPath: "/",
+ outputDir: "dist", //输出文件类型
+ productionSourceMap: false, //打包时候js是否添加sourceMap
+};
diff --git a/package.json b/package.json
index 5bcdd963..249bdde6 100644
--- a/package.json
+++ b/package.json
@@ -73,6 +73,7 @@
"@vue/compiler-sfc": "^3.2.4",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^7.0.0",
+ "base64-inline-loader": "^2.0.1",
"electron": "^11.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^7.29.0",
@@ -81,6 +82,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
+ "html-webpack-inline-source-plugin": "^0.0.10",
"husky": "^6.0.0",
"openapi-types": "^9.3.0",
"sass": "~1.32.6",
diff --git a/public/index.html b/public/index.html
index 3b324b1d..6a616fd2 100644
--- a/public/index.html
+++ b/public/index.html
@@ -7,16 +7,8 @@
-
-
-
+
+
<% if (process.env.NODE_ENV === "production") { %>
<% } %>
diff --git a/vue.config.js b/vue.config.js
index 8244d9ea..bd0f8705 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,127 +1,24 @@
-/**
- * @description electron默认打包配置
- * @author shuxiaokai
- */
-// eslint-disable-next-line @typescript-eslint/no-var-requires
-const path = require("path");
-const buildShare = process.argv.find((val) => val === "--share");
+/* eslint-disable @typescript-eslint/no-var-requires */
+const htmlBuildConfig = require("./build/html.config");
+const defaultBuildConfig = require("./build/default.config");
+const shareBuildConfig = require("./build/share.config");
+
+const buildShare = process.argv.find(val => val === "--share");
const buildHtml = process.argv.find((val) => val === "--html");
process.env.VUE_APP_BUILD_TIME = new Date().toLocaleString();
process.env.VUE_APP_BUILD_SHARE = buildShare;
process.env.VUE_APP_BUILD_HTML = buildHtml;
+let vueConfig = null;
+
+
+if (buildHtml) {
+ vueConfig = htmlBuildConfig
+} else if (buildShare) {
+ vueConfig = shareBuildConfig;
+} else {
+ vueConfig = defaultBuildConfig
+}
-console.log((buildShare || buildHtml) ? "src/renderer/pages/modules/apidoc/doc-view/main.ts" : "src/renderer/main.ts")
-module.exports = {
- pages: {
- index: {
- entry: (buildShare || buildHtml) ? "src/renderer/pages/modules/apidoc/doc-view/main.ts" : "src/renderer/main.ts", //添加了entry则不需要rendererProcessFile
- template: "public/index.html",
- },
- },
- //=====================================devserver====================================//
- devServer: {
- port: 9999,
- },
- //=====================================css相关配置====================================//
- css: {
- loaderOptions: {
- css: {
- // 这里的选项会传递给 css-loader
- },
- sass: {
- prependData: `@import "@/scss/index.scss";`,
- },
- },
- sourceMap: false,
- },
- //=====================================扩展webpack配置====================================//
- configureWebpack: {
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "./src/renderer"),
- "@@": path.resolve(__dirname, "./src"),
- "~": path.resolve(__dirname, "./"),
- },
- },
- target: "web"
- },
- pluginOptions: {
- electronBuilder: {
- // contextIsolation: false,
- nodeIntegration: true, //参考https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html
- extends: null,
- externals: [
- "vue",
- "axios",
- "vue-electron",
- "vue-router",
- "vuex",
- "vuex-electron",
- "element-ui",
- "js-cookie",
- "mockjs",
- "nprogress",
- "monaco-editor",
- "vuedraggable",
- "ali-oss",
- "json5",
- "echarts",
- "brace",
- "urllib",
- "got",
- "@koa/cors",
- "form-data",
- "proxy-agent",
- "shelljs",
- "ssh2",
- "koa",
- "internal-ip",
- ],
- mainProcessFile: "src/main/background.ts",
- mainProcessWatch: ["src/main/background.ts"],
- builderOptions: {
- productName: "快乐摸鱼",
- appId: "com.example.yourapp",
- publish: [
- {
- provider: "generic",
- url: "",
- },
- ],
- nsis: {
- oneClick: false, // 是否一键安装
- allowToChangeInstallationDirectory: true, // 允许修改安装目录
- },
- mac: {
- icon: "public/icons/icon.icns",
- },
- win: {
- icon: "public/icons/icon.ico",
- },
- linux: {
- icon: "public/icons",
- },
- },
- //参考 https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/1432
- chainWebpackMainProcess: config => {
- config.module
- .rule("babel")
- .before("ts")
- .use("babel")
- .loader("babel-loader")
- .options({
- presets: [["@babel/preset-env", { modules: false, targets: { electron: "6" } }]],
- plugins: ["@babel/plugin-proposal-class-properties"]
- })
- }
- },
- },
- //=====================================eslint配置====================================//
- lintOnSave: "error", //未通过eslint 禁止代码提交
- //=====================================打包上线配置====================================//
- publicPath: "/",
- outputDir: "dist", //输出文件类型
- productionSourceMap: false, //打包时候js是否添加sourceMap
-};
+module.exports = vueConfig
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index ec5e0480..031b98d6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2868,6 +2868,14 @@ balanced-match@^1.0.0:
resolved "https://registry.nlark.com/balanced-match/download/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=
+base64-inline-loader@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.npmmirror.com/base64-inline-loader/download/base64-inline-loader-2.0.1.tgz#bb5f2a79007bc291f7298c32ef5295b7b450a9b2"
+ integrity sha1-u18qeQB7wpH3KYwy71KVt7RQqbI=
+ dependencies:
+ loader-utils "^2.0.0"
+ mime-types "^2.1.32"
+
base64-js@^1.0.2, base64-js@^1.3.1, base64-js@^1.5.1:
version "1.5.1"
resolved "https://registry.nlark.com/base64-js/download/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -6615,6 +6623,15 @@ html-tags@^3.1.0:
resolved "https://registry.nlark.com/html-tags/download/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
integrity sha1-e15vfmZen7QfMAB+2eDUHpf7IUA=
+html-webpack-inline-source-plugin@^0.0.10:
+ version "0.0.10"
+ resolved "https://registry.nlark.com/html-webpack-inline-source-plugin/download/html-webpack-inline-source-plugin-0.0.10.tgz#89bd5f761e4f16902aa76a44476eb52831c9f7f0"
+ integrity sha1-ib1fdh5PFpAqp2pER261KDHJ9/A=
+ dependencies:
+ escape-string-regexp "^1.0.5"
+ slash "^1.0.0"
+ source-map-url "^0.4.0"
+
html-webpack-plugin@^3.2.0:
version "3.2.0"
resolved "https://registry.nlark.com/html-webpack-plugin/download/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b"
@@ -8265,7 +8282,7 @@ mime-db@1.49.0:
resolved "https://registry.nlark.com/mime-db/download/mime-db-1.49.0.tgz#f3dfde60c99e9cf3bc9701d687778f537001cbed"
integrity sha1-89/eYMmenPO8lwHWh3ePU3ABy+0=
-"mime-db@>= 1.43.0 < 2":
+mime-db@1.50.0, "mime-db@>= 1.43.0 < 2":
version "1.50.0"
resolved "https://registry.nlark.com/mime-db/download/mime-db-1.50.0.tgz#abd4ac94e98d3c0e185016c67ab45d5fde40c11f"
integrity sha1-q9SslOmNPA4YUBbGerRdX95AwR8=
@@ -8277,6 +8294,13 @@ mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24:
dependencies:
mime-db "1.49.0"
+mime-types@^2.1.32:
+ version "2.1.33"
+ resolved "https://registry.npmmirror.com/mime-types/download/mime-types-2.1.33.tgz#1fa12a904472fafd068e48d9e8401f74d3f70edb"
+ integrity sha1-H6EqkERy+v0GjkjZ6EAfdNP3Dts=
+ dependencies:
+ mime-db "1.50.0"
+
mime@1.6.0:
version "1.6.0"
resolved "https://registry.nlark.com/mime/download/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"