Ai
2 Star 0 Fork 0

longxiaobaiWJ/electron-learn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 5.38 KB
一键复制 编辑 原始数据 按行查看 历史
front_clone 提交于 2024-04-05 14:26 +08:00 . feat: 格式化代码
const path = require('path')
const webpack = require('webpack')
const HtmlPrettyConsoleWebpackPlugin = require('html-pretty-console-webpack-plugin')
const MyCustomPlugin = require('./plugins/dlts-webpack-plugin.js')
module.exports = {
productionSourceMap: false,
pluginOptions: {
electronBuilder: {
builderOptions: {
appId: 'com.learn.app',
productName: 'Learn', // 项目名,也是生成的安装文件名,即 electron.exe
asar: true,
copyright: 'Copyright © 2023 learn.com All Rights Reserved', // 版权信息
directories: {
output: 'release' // 输出文件路径
},
win: {
icon: 'dist_electron/icons/icon.ico',
target: [{
target: 'nsis', // 利用nsis制作安装程序
arch: ['x64', 'ia32']
}]
},
nsis: {
allowElevation: true, // 允许请求提升
oneClick: false, // 是否一键安装
allowToChangeInstallationDirectory: true, // 允许修改安装目录
installerIcon: 'dist_electron/icons/icon.ico', // 安装图标
uninstallerIcon: 'dist_electron/icons/icon.ico', // 卸载图标
installerHeaderIcon: 'dist_electron/icons/icon.ico', // 安装时头部图标
createDesktopShortcut: true, // 创建桌面图标
createStartMenuShortcut: true, // 创建开始菜单图标
shortcutName: 'electron-learn', // 图标名称
runAfterFinish: false // 是否安装完成后运行
// perMachine: true, // 是否开启安装时权限限制
// guid: 'electron-learn',
// include: 'build/installer.nsh', // 包含的自定义nsis脚本
},
dmg: {
icon: 'dist_electron/icons/icon.icns',
iconSize: 100, // 图标的尺寸
contents: [
{
x: 410,
y: 150,
type: 'link',
path: '/Applications'
},
{
x: 130,
y: 150,
type: 'file'
}
]
},
// pkg: {
// welcome: 'Hello Learn'
// },
mac: {
icon: 'dist_electron/icons/icon.icns',
// identity: 'xxxxx',
category: 'public.app-category.utilities', // 应用类型
hardenedRuntime: true,
gatekeeperAssess: false,
target: ['dmg', 'zip', 'pkg'],
darkModeSupport: true
},
publish: [{
provider: 'generic',
url: 'http://192.168.101.112:8080/electrons/'
}],
// files: ['**/*', '!node_modules/**/*'],
files: ['!node_modules/**/*'],
beforeBuild (context) {
console.log(context)
console.log('-----------------')
return null
}
},
nodeIntegration: true,
preload: path.join(__dirname, 'src/preload.ts'),
chainWebpackMainProcess: (config) => {
config.plugin('env').tap(args => {
args[0].LG_CY_NAME = 'LG_CY_NAME'
return args
})
}
}
},
configureWebpack: {
mode: process.env.NODE_ENV
},
chainWebpack: config => {
// https://blog.csdn.net/qq_41887214/article/details/129567640
// config.module
// .rule('ts')
// .use('transfer-loader')
// .loader('./loaders/transfer-loader.js')
// .before('babel-loader')
// .end()
config.module
.rule('transfer')
.test(/\.ts$/)
.use('cache-loader')
.loader('cache-loader')
.end()
.use('transfer-loader')
.loader('./loaders/transfer-loader.js')
.after('babel-loader')
.tap(() => {
return {
name: '[chunkhash:8]'
}
})
.end()
.use('babel-loader')
.loader('babel-loader')
.end()
.use('ts-loader')
.loader('ts-loader')
.tap(() => {
return {
transpileOnly: true,
appendTsSuffixTo: [
'\\.vue$'
],
happyPackMode: false
}
})
.end()
.include
.add(path.resolve('./src/components'))
.end()
// https://blog.csdn.net/qq_41887214/article/details/129567640
config.plugin('define').tap(args => {
console.log('----- define -----');
const stVal = args[0]
return [ { 'process.env': { ...stVal['process.env'], NEW_SMILE: '2024'}} ]
})
config.plugin('re-define').use(webpack.DefinePlugin, [
{
'process.env': {
CURRENT_LOGIN: Date.now(),
ELECTRON_IS_AUTH: true,
ELECTRON_NAME: '"Smile Electron"'
}
}
]).before('define')
config.plugin('env').use(webpack.EnvironmentPlugin, [{
LY_SMILE_NAME: 'LY_SMILE_NAME'
}])
config.plugin('console').use(HtmlPrettyConsoleWebpackPlugin, [{
output: [
{ label: '分支信息', value: 'master' },
{ label: '打包时间', value: new Date().toString() }
]
}])
config.plugin('custom-plugin').use(MyCustomPlugin).after('vue-loader')
// 查看框架内已配置的 Plugins VS Loaders
const webpackConfig = config.toConfig()
const plugins = webpackConfig.plugins
console.log(config.module.rules.store.keys())
console.log(config.plugins.store.keys())
// console.log(webpackConfig.module.rules);
console.log('=== Used Plugins ===', plugins.length)
console.log(plugins.map(plugin => plugin.constructor.name))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/frontend_site/electron-learn.git
git@gitee.com:frontend_site/electron-learn.git
frontend_site
electron-learn
electron-learn
master

搜索帮助