electron-vue项目启动
- 通过vue-cli构建
指令:
vue init simulatedgreg/electron-vue my-project
- 创建后进行包安装
yarn
或者
npm install
Electron-vue ReferenceError: process is not defined
修改你项目文件下.electron-vue里面的webpack.renderer.config.js和webpack.web.config.js
./.electron-vue文件
两个文件修改的内容都是一样的
new HtmlWebpackPlugin({
filename: '',
template: path.resolve(__dirname, '../src/index.ejs'),
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: compilation.getStats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
},
nodeModules: false
}),
最终webpack.web.config.js修改完成后内容如下:
webpack.web.config.js添加的内容
而webpack.renderer.config.js修改完成后的内容如下:
webpack.renderer.config.js添加的内容
修改后可能会出现另一个问题:
Cannot find module 'axios’等问题
解决方案:
在webpack.render.config.js中 找到
let whiteListedModules = ['vue']
将其修改为:
let whiteListedModules = ['vue','axios','vue-electron', 'vue-router', 'vuex', 'vuex-electron','element-ui']
本文地址:https://blog.csdn.net/qq_44831027/article/details/108874837
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论