electron-vue项目启动&&解决 process is not defined以及带来的Cannot find module ‘axios‘等问题
程序员文章站
2022-04-01 19:33:48
electron-vue项目启动通过vue-cli构建指令:vue init simulatedgreg/electron-vue my-project创建后进行包安装yarn或者npm installElectron-vue ReferenceError: process is not defined修改你项目文件下.electron-vue里面的webpack.renderer.config.js和webpack.web.config.js./.electron-vue...
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: 'index.html',
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