You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

86 lines
1.9 KiB

const path = require('path')
const { defineConfig } = require('@vue/cli-service')
const appRoot = path.resolve(__dirname)
module.exports = defineConfig({
outputDir: path.join(appRoot, 'dist/renderer'),
publicPath: './',
configureWebpack: {
target: 'electron-renderer',
node: {
global: false, // 禁用全局 polyfill
__dirname: true
},
resolve: {
fallback: {
global: false // 禁用 fallback
},
alias: {
'@': path.join(appRoot, 'src/renderer'),
'views': path.join(appRoot, 'src/renderer/views')
},
extensions: ['.js', '.vue', '.json']
},
externals: {
electron: 'require("electron")',
fs: 'require("fs")',
path: 'require("path")'
}
},
pages: {
index: {
entry: path.join(appRoot, 'src/renderer/main.js'),
template: path.join(appRoot, 'public/index.html'),
filename: 'index.html'
}
},
pluginOptions: {
electronBuilder: {
preload: path.join(appRoot, 'src/preload.js'),
mainProcessFile: path.join(appRoot, 'src/main/index.js'),
builderOptions: {
extraResources: [{
from: path.join(appRoot, 'dist/renderer'),
to: 'app',
filter: ["**/*"]
}]
}
}
},
devServer: {
hot: false,
liveReload: false,
allowedHosts: "all",
static: {
directory: path.join(__dirname, 'dist/renderer'),
watch: false
},
compress: false,
proxy: null
},
chainWebpack: config => {
// 开发环境 sourcemap
config.devtool(process.env.NODE_ENV === 'development'
? 'source-map'
: false)
// 静态资源处理
config.module
.rule('images')
.set('generator', {
filename: 'img/[name].[hash:8][ext]'
})
// 全局变量定义
config.plugin('define').tap(args => {
args[0]['global.GLOBAL'] = JSON.stringify(false)
return args
})
}
})