I recently upgraded my Quasar framework to v2 which uses Vue3, Electron 16 and Webpack 5.
When I tried to run my application, I keep getting this error:
Module not found: Can't resolve imported dependency "fs"
I understand that webpack 5 does not automatically do polyfills so I added these in my quasar.conf.js:
chainWebpack (chain) {
const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
chain.plugin('node-polyfill').use(nodePolyfillWebpackPlugin)
}
But this doesn't support polyfills for the fs module.
When I tried adding this:
if (!cfg.resolve.fallback) {
cfg.resolve.fallback = {}
cfg.resolve.fallback.fs = false
}
Now I get an error:
TypeError: fs.readFileSync is not a function
I also tried adding this in my package.json, same behavior (as expected):
"browser": {
"fs": false
}
But then.. How can I use fs in my electron application?