代码拉取完成,页面将自动刷新
const {
appName,
} = require('./src/config/index');
const {
isExist,
pathJoin,
} = require('./src/utils/node');
module.exports = {
pages: createPages('./src/windows'),
pluginOptions: {
electronBuilder: {
mainProcessFile: './src/background/index.js',
mainProcessWatch: ['./src/background/**'],
nodeIntegration: true,
builderOptions: {
npmRebuild: false,
productName: appName,
appId: 'com.jar.starter.box',
win: {
icon: 'public/logos/index.ico',
target: 'nsis',
},
},
},
},
chainWebpack(config) {
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(pathJoin('src/icons'))
.end();
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(pathJoin('src/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'svg-[name]',
})
.end();
},
};
function createPages(dirPath) {
const isCanDir = isExist(dirPath);
let files = [];
if (isCanDir) {
const klawSync = require('klaw-sync');
// @ts-ignore
files = klawSync(dirPath, {
nodir: true,
traverseAll: true,
filter({
path,
}) {
return !!path.match(/main\.js/);
},
});
}
// console.log('files', files);
const windowsPathLength = pathJoin(dirPath).length;
const regExp = process.platform !== 'win32' ? /\//g : /\\/g;
// 入口页面
const initPage = {
index: {
entry: './src/main.js',
template: './public/index.html',
filename: 'index.html',
title: appName,
},
};
const pages = files.reduce((obj, {
path,
}) => {
const filename = path
.substring(windowsPathLength + 1)
.replace(regExp, '_')
.replace(/_main/, '')
.replace(/\.js$/, '.html');
console.log('filename', filename);
const pageName = filename.substring(0, filename.lastIndexOf('.'));
console.log('pageName', pageName);
obj[pageName] = {
entry: path,
template: './public/index.html',
filename,
title: appName,
};
return obj;
}, initPage);
return pages;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。