S
S
skuvaWeb2021-10-11 16:58:59
Vue.js
skuvaWeb, 2021-10-11 16:58:59

Vue-cli-pwa-plugin how to include service worker in build?

I have a problem with the service worker
I don't understand how to correctly include the service worker in the webpack build in order to minify the file and have access to the env variables

I'm using the official plugin https://github.com/vuejs/vue-cli/tree/dev/ packages...

It adds file to connect service worker https://github.com/vuejs/vue-cli/blob/dev/packages...

There are 2 scenarios:
1. I add worker in public folder then worker is connected, but it is excluded from the webpack build process, it is not minified and has no access to env

2. I include the worker file in main.js, then it goes into dist/js/[hashname].js like other files and I can't include it via register-service-worker

How can I include a worker in the assembly so that there is minification and access to env?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
skuvaWeb, 2021-10-12
@skuvaWeb

Solution in this loader - https://github.com/mohsen1/service-worker-loader

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question