I would like to apply PWA in nuxt(@2.3.4
) web application.
The operating system is OSX
latest.
So I have installed @nuxtjs/pwa
and add some config to nuxt.config.js
.
These are what I have added
module.exports = {
...
modules: [
['@nuxtjs/pwa', {icon : false}]
],
workbox : {
dev: true,
debug: true
},
manifest : {
viewport: 'width=device-width, initial-scale=1',
theme_color: '#3B8070'
},
...
}
And build with NODE_ENV=production
and start.
I am able to find sw.js
in localhost:9000
, but it is not available with
local.jy.net:9000
.
I was expecting the same result since I register that hostname on my hosts
file.
Here is what I have in /private/etc/hosts
.
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 Juneui-MacBook-Pro.local
127.0.0.1 local.jy.net aad901eb546340cc9a69b0b030b124fc.jy.net
How could I make @nuxtjs/pwa
refers system hosts variables?
If you need more information, add reply then I will provide as possible as I can. Thanks.
The @nuxtjs/pwa
package is looking for the build.publicPath
option: https://github.com/nuxt-community/pwa-module/blob/9f27d5cdae0e0341d6d4b4f6814f91db6eab1432/packages/manifest/index.js#L24
Adding this option to your nuxt.config.js
should do the trick:
module.exports = {
...
modules: [
['@nuxtjs/pwa', {icon : false}]
],
workbox : {
dev: true,
debug: true
},
manifest : {
viewport: 'width=device-width, initial-scale=1',
theme_color: '#3B8070'
},
build: {
publicPath: '//local.jy.net:9000/pwa/',
}
...
}
You can find more information about the publicPath
property here: https://nuxtjs.org/api/configuration-build#publicpath