electron-vue在使用electron-vue時候,執行npn run dev,會出現下面的錯誤解決方法:
找到根目錄下的.electron-vue目錄
找到該目錄下的webpack.renderer.config.js檔案,找到這段程式碼
new HtmlWebpackPlugin({ // ...})
用下面的程式碼將這段程式碼替換:
new HtmlWebpackPlugin({ filename: 'index.html', template: path.resolve(__dirname, '../src/index.ejs'), minify: { collapseWhitespace: true, removeAttributeQuotes: true, removeComments: true }, templateParameters(compilation, assets, options) { return { compilation: compilation, webpack: compilation.getStats().toJson(), webpackConfig: compilation.options, htmlWebpackPlugin: { files: assets, options: options }, process, }; }, nodeModules: process.env.NODE_ENV !== 'production' ? path.resolve(__dirname, '../node_modules') : false }),
再找到該目錄下的webpack.web.config.js檔案,找到這段程式碼:
new HtmlWebpackPlugin({ // ...})
用下面的程式碼將這段程式碼替換
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}),
最後重新編譯就解決了
yarn run dev
引用自
https://zhuanlan.zhihu.com/p/110792626