forked from trueleaf/moyu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c802b31
commit 3fcea91
Showing
4 changed files
with
186 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/** | ||
* @description electron默认打包配置 | ||
* @author shuxiaokai | ||
*/ | ||
const path = require("path"); | ||
const config = require("../src/config"); | ||
|
||
module.exports = { | ||
pages: { | ||
index: { | ||
entry: "src/renderer/main.js", //添加了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, "../"), | ||
}, | ||
}, | ||
}, | ||
pluginOptions: { | ||
electronBuilder: { | ||
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", | ||
"cookie-parser", | ||
"got", | ||
"form-data", | ||
"proxy-agent", | ||
], | ||
mainProcessFile: "src/main/index.js", | ||
mainProcessWatch: ["src/main/index.js"], | ||
builderOptions: { | ||
productName: config.renderConfig.layout.title, | ||
appId: "com.example.yourapp", | ||
publish: [ | ||
{ | ||
provider: "generic", | ||
url: "", | ||
}, | ||
], | ||
nsis: { | ||
oneClick: false, // 是否一键安装 | ||
allowToChangeInstallationDirectory: true, // 允许修改安装目录 | ||
}, | ||
mac: { | ||
icon: "build/icons/icon.icns", | ||
}, | ||
win: { | ||
icon: "build/icons/icon.ico", | ||
}, | ||
linux: { | ||
icon: "build/icons", | ||
}, | ||
}, | ||
}, | ||
}, | ||
//=====================================eslint配置====================================// | ||
lintOnSave: "error", //未通过eslint 禁止代码提交 | ||
//=====================================打包上线配置====================================// | ||
publicPath: config.build.publicPath || "/", | ||
outputDir: "dist", //输出文件类型 | ||
productionSourceMap: true, //打包时候js是否添加sourceMap | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @description 默认打包配置 | ||
* @author shuxiaokai | ||
*/ | ||
const path = require("path"); | ||
const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin"); | ||
const config = require("../src/config"); | ||
|
||
module.exports = { | ||
//=====================================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: config.build.publicPath || "/", | ||
}, | ||
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|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 禁止代码提交 | ||
//=====================================打包上线配置====================================// | ||
publicPath: config.build.publicPath || "/", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,159 +1,33 @@ | ||
const path = require("path"); | ||
const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin"); | ||
const minimist = require("minimist"); | ||
const config = require("./src/config"); | ||
const defaultBuildConfig = require("./build/default.build"); | ||
const singleBuildConfig = require("./build/single.build"); | ||
|
||
process.env.VUE_APP_TITLE = config.renderConfig.layout.title; | ||
const isShareDoc = process.argv.find((val) => val === "--single"); | ||
const rawArgv = process.argv.slice(2); | ||
const argv = minimist(rawArgv); | ||
const buildWebPage = argv.web; //在线连接和生成静态HTML页面 | ||
const buildSingleWebPage = argv.offline; //仅生成单个文件 | ||
|
||
let vueConfig = {}; | ||
if (isShareDoc) { | ||
vueConfig = { | ||
//=====================================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: config.build.publicPath || "/", | ||
}, | ||
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|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 禁止代码提交 | ||
//=====================================打包上线配置====================================// | ||
publicPath: config.build.publicPath || "/", | ||
// outputDir: "dist", //输出文件类型 | ||
}; | ||
if (buildSingleWebPage) { | ||
vueConfig = singleBuildConfig; | ||
} else if (buildWebPage) { | ||
delete defaultBuildConfig.pages; | ||
vueConfig = defaultBuildConfig; | ||
} else { | ||
vueConfig = { | ||
pages: { | ||
index: { | ||
entry: "src/renderer/main.js", //添加了entry则不需要rendererProcessFile | ||
template: "public/index.html", | ||
defaultBuildConfig.css = { | ||
loaderOptions: { | ||
css: { | ||
// 这里的选项会传递给 css-loader | ||
}, | ||
}, | ||
//=====================================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, ""), | ||
}, | ||
}, | ||
}, | ||
pluginOptions: { | ||
electronBuilder: { | ||
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", | ||
"cookie-parser", | ||
"got", | ||
"form-data", | ||
"proxy-agent", | ||
], | ||
mainProcessFile: "src/main/index.js", | ||
mainProcessWatch: ["src/main/index.js"], | ||
builderOptions: { | ||
productName: config.renderConfig.layout.title, | ||
appId: "com.example.yourapp", | ||
publish: [ | ||
{ | ||
provider: "generic", | ||
url: "", | ||
}, | ||
], | ||
nsis: { | ||
oneClick: false, // 是否一键安装 | ||
allowToChangeInstallationDirectory: true, // 允许修改安装目录 | ||
}, | ||
mac: { | ||
icon: "build/icons/icon.icns", | ||
}, | ||
win: { | ||
icon: "build/icons/icon.ico", | ||
}, | ||
linux: { | ||
icon: "build/icons", | ||
}, | ||
}, | ||
sass: { | ||
prependData: `@import "@/scss/index.scss";`, | ||
}, | ||
}, | ||
//=====================================eslint配置====================================// | ||
lintOnSave: "error", //未通过eslint 禁止代码提交 | ||
//=====================================打包上线配置====================================// | ||
publicPath: config.build.publicPath || "/", | ||
outputDir: "dist", //输出文件类型 | ||
productionSourceMap: true, //打包时候js是否添加sourceMap | ||
sourceMap: false, | ||
}; | ||
vueConfig = defaultBuildConfig | ||
} | ||
|
||
module.exports = vueConfig; |