framework7io / framework7-template-vue-webpack

Deprecated! Framework7 Vue Webpack starter app template with hot-reload & css extraction
https://framework7.io/vue/
MIT License
384 stars 136 forks source link

add a service worker with global scope #73

Closed kjj77 closed 5 years ago

kjj77 commented 5 years ago

Hi,

not really an issue but more a question about the file structure: how can I put a service-worker.js file in a way that I can call it later with a global scope ? If I put it in /static/service-worker.js, in the output it will be in the /www/static directory, so I will not be able to call it with a global scope for my app from a subfolder. If I put it in /src/service-worker.js, it just won't be copied to the www folder. Shall I add as another entry point in webpack ? If so, how ? Any suggestion will be appreciated...

kjj77 commented 5 years ago

Actually, since I'm trying to build a PWA, the same applies to the manifest.json, which is deleted in the www folder each time I run

npm run dev

because not "registered" somewhere I suppose

kjj77 commented 5 years ago

I managed to do it by adding these lines to CopyWebPack plugin in webpack config :

new CopyWebpackPlugin([{ from: resolvePath('static'), to: resolvePath('www/static'), },{ from: resolvePath('src/sw.js'), to: resolvePath('www/sw.js') } ])