加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const MangleJsClassPlugin = require("mangle-js-webpack-plugin");
const MonacoEditorPlugin = require("monaco-editor-webpack-plugin");
const path = require("path");
const appMode = process.env.VUE_APP_MODE;
console.log(`Current Mode: ${appMode}`);
const isWeb = appMode === "web";
let distPath = path.join(__dirname, "dist");
let copyPattern = {
from: path.join(__dirname, "README.md"),
to: path.join(distPath, "README.md")
};
console.log(`Current Node Mode: ${process.env.NODE_ENV}`);
module.exports = {
publicPath: isWeb ? "/" : "./",
productionSourceMap: false,
outputDir: distPath,
chainWebpack: config => {
config.plugin("copy-plugin").use(CopyPlugin, [
{
patterns: [copyPattern]
}
]);
config.plugin("monaco-editor-plugin").use(MonacoEditorPlugin, [
{
features: ["!gotoSymbol"],
languages: ["json"]
}
]);
if (process.env.NODE_ENV === "production") {
config.optimization.minimizer("terser").use(TerserPlugin, [
{
terserOptions: {
compress: {
pure_funcs: ["console.log"]
}
}
}
]);
config.plugin("mangle-plugin").use(MangleJsClassPlugin, [
{
algorithm: "obfuscator",
algorithmConfig: {
prefix: "focus",
log: false
}
}
]);
}
},
pluginOptions: {
electronBuilder: {
builderOptions: {
appId: "com.lanyuanxiaoyao.searchx",
files: [
"**/*",
{
from: "node_modules",
to: "node_modules",
filter: ["**/*"]
}
],
mac: {
category: "public.app-category.utilities",
icon: "icons/icon.icns",
target: ["dmg", "7z", "zip"],
// TODO: electron-builder 的 bug 导致该参数会组织构建, 暂时注释, 之后新版本出来后修复
// electronLanguages: ["en", "zh_CN", "zh_TW"]
},
win: {
icon: "icons/icon.ico",
target: ["nsis", "portable"]
},
nsis: {
oneClick: false,
perMachine: false,
allowToChangeInstallationDirectory: true,
installerIcon: "icons/icon.ico",
differentialPackage: false
},
dmg: {
writeUpdateInfo: false
},
linux: {
icon: "icons/icon.png",
target: ["AppImage", "deb", "rpm"],
category: "Network"
}
}
}
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化