Раньше я использовал elctron-vue
=> electron5 + webpack
Теперь я обновил его до vue-cli4 + elctron8
, у меня проблема!
Вот ошибка:
Building modern bundle for production...(node:11124) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'D:\xxx\electron-vue-demo\dist_electron\bundled\legacy-assets-index.json'
Я могу успешно выполнить локальный отладочный прогон, но сборщик не смог.
legacy-assets-index.json
Я посмотрел его, и кажется, что автоматиз c поколение.
Я проверил документ cli4 ниже, но я не нашел причину.
Вот мой vue.config.js
let path = require('path')
let glob = require('glob') // 用于筛选文件
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin');
function resolve(dir) {
return path.join(__dirname, dir)
}
// 工厂函数 - 配置pages实现多页面获取某文件夹下的html与js
function handleEntry(entry) {
let entries = {}
let entryBaseName = ''
let entryPathName = ''
let entryTemplate = ''
glob.sync(entry).forEach(item => {
console.log('!!!', item)
entryTemplate = item.split('/').slice(0, 5)
console.log('entryTemplate:', entryTemplate)
entryBaseName = entryTemplate[4]
console.log('entryBaseName:', entryBaseName)
entryPathName = entryBaseName // 正确输出js和html的路径
console.log('entryPathName', entryPathName)
entries[entryPathName] = {
app: `.\\` + path.join(...entryTemplate, 'main.js'),
entry: `.\\` + path.join(...entryTemplate, 'main.js'),
template: `.\\` + path.join(...entryTemplate, 'public', 'index.html'),
// title: entryPathName,
filename: entryPathName
}
})
return entries
}
let pages = handleEntry('./src/renderer/pages/**?/public/index.html')
let WebpackRenderer = config => {
config.plugin('define').use(webpack.DefinePlugin, [{
'process.env': {
NODE_ENV: '"production"',
BASE_URL: '`require("electron").remote.app.getAppPath()`',
IS_ELECTRON: true
},
__dirname: '`require("electron").remote.app.getAppPath()`',
__filename: '`${require("electron").remote.app.getAppPath()}/index.html`',
__static: '`require("electron").remote.app.getAppPath()`'
}])
config.entryPoints.clear() // 会把默认的入口清空
Object.keys(pages).forEach(entryName => {
// config.plugin('html').use(HtmlWebpackPlugin, [pages[entryName]])
config.plugin(`html-${entryName}`).use(HtmlWebpackPlugin, [pages[entryName]])
config.entry(entryName).add( pages[entryName].entry)
})
console.log(config.toString())
}
module.exports = {
configureWebpack: {
// Configuration applied to all builds
},
pluginOptions: {
electronBuilder: {
chainWebpackMainProcess: config => {
// Chain webpack config for electron main process only
},
chainWebpackRendererProcess: WebpackRenderer,
// Use this to change the entrypoint of your app's main process
mainProcessFile: 'src/electron/main.js',
// Provide an array of files that, when changed, will recompile the main process and restart Electron
// Your main process file will be added by default
// mainProcessWatch: ['src/myFile1', 'src/myFile2'],
// [1.0.0-rc.4+] Provide a list of arguments that Electron will be launched with during "electron:serve",
// which can be accessed from the main process (src/background.js).
// Note that it is ignored when --debug flag is used with "electron:serve", as you must launch Electron yourself
// Command line args (excluding --debug, --dashboard, and --headless) are passed to Electron as well
mainProcessArgs: ['--arg-name', 'arg-value']
},
}
}
Мой английский sh не очень хорош, если вы не понимаете вопрос, я могу продолжать заполнять детали