mirror of https://gitee.com/shuzhikai/apiflow.git
cli: 区分打包方式
parent
73af94d239
commit
e71353abb3
@ -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
|
||||
};
|
@ -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: "/",
|
||||
};
|
@ -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
|
||||
};
|
@ -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
|
Loading…
Reference in New Issue