webpack is in --watch mode in quasar pwa. how to change
- User
webpack is in --watch mode in quasar pwa. how to change
- Assistant
To change the webpack watch mode settings in Quasar PWA, you can follow the below steps:
-
Open the
quasar.conf.jsfile located in the root directory of your project. -
Look for the
buildproperty and thenextendWebpackproperty inside it. -
Add the
watchOptionsproperty with your desired configuration. For example:extendWebpack(cfg) { cfg.watchOptions = { ignored: /node_modules/, poll: 1000 }; }In this example, we added
ignoredandpollconfiguration options to thewatchOptionsproperty. -
Save the file and restart your development server.
Note: The
watchOptionsproperty is an object that accepts various values to configure the webpack watch mode. You can refer to the webpack documentation for more details on the available options. -
- User
how to stop new generatesw file from generating everytime i make changes in quasar app
- Assistant
To stop generating a new service worker file (
generateSW) every time changes are made in your Quasar app, you can follow these steps:-
Open the
quasar.conf.jsfile in your project's root directory. -
Look for the
pwaproperty inside thebuildobject and add theskipWaitingoption:pwa: { skipWaiting: true }This will prevent the updated service worker from waiting for active clients to close before activating.
-
Open the
src-pwa/sw.jsfile in your project and check if there are any precaching URLs. If there are, you can remove them, they are unnecessary.precacheAndRoute([ '/index.html' ])If there are no precaching URLs defined in your file, you can leave it as is.
-
Save the changes to your
quasar.conf.jsfile andsw.js, then restart your development server.
With this configuration, the Quasar app will use the same service worker that was previously generated, and it will not be overwritten with a new version every time changes are made. However, you may need to manually unregister the previous service worker when deploying updates to make sure the new version takes effect.
-
- User
im only using quasar dev, not build
- Assistant
If you are only using
quasar devand not building your app for production, you don't need to modify thequasar.conf.jsfile. The service worker (generateSW) is only generated during the production build process and will not be used during development.Therefore, you can simply ignore the service worker generated during development as it will be overwritten when you generate the service worker during production builds.
However, if you want to disable the service worker in development mode, you can add the following code to your
src/index.template.htmlfile to prevent the service worker from being registered:<script> if ('serviceWorker' in navigator) { navigator.serviceWorker.ready .then(registration => { registration.unregister(); }); } </script>Keep in mind that this will only disable the service worker during development and will not affect the production build.