I have the following problem. I am using nuxt with the pwa module to generate a pre-rendered webpage. The @nuxt/pwa icon module should generate the different sized icons for the manifest.
This is also working when I run nuxt generate
on my laptop.
In my gitlab-ci pipeline the generation also is working but it is always generating the default nuxt icon
This icon I can not in my workspace so I guess it is somehow referenced in the docker build from node_modules.
I am using the following gitlab-ci job
build:
image: node:alpine
stage: build
script:
- npm run generate
artifacts:
paths:
- dist/*
expire_in: 14 days
only:
- master
The package.json
looks like this:
"scripts": {
"generate": "nuxt generate",
...
},
"dependencies": {
"@nuxtjs/pwa": "^3.0.0-beta.20",
"nuxt": "^2.14.0",
...
},
"devDependencies": {
...
}
I also tried a lot of different settings in my nuxt.conf.js as I guessed that the icon is not referenced correctly.
This was my last try
pwa: {
icon: {
source: resolve(__dirname, './client/static/icon.png'),
},
},
But as it is found locally I thik that it is right.
Has anyone an idea why the nuxt generate
does not work in gitlab-ci?
The Nuxt. js PWA module registers a service worker for you to deal with offline caching. It automatically generates a manifest.json file. It automatically adds SEO friendly meta data with manifest integration. It automatically generates app icons with different sizes.
Step 1: Add Google fonts icon's CDN. Step 2: Use it (you are done!) Here is the complete list of Material Icons. Show activity on this post.
⚡ Nuxt PWA. Progressive Web Apps (PWA) are reliable, fast, and engaging, although there are many things that can take a PWA from a baseline to exemplary experience.
Zero config PWA solution for Nuxt.js Registers a service worker for offline caching. Automatically generate manifest.json file. Automatically adds SEO friendly meta data with manifest integration.
The issue seems to be the old cache located at /node_modules/.cache/pwa/icon Nuxt doesn't generate new icons if the filenames are not changed so that is why the default icons are used. Especially if your new icon file is 'icon.png'.
The generation of routes are concurrent, generate.concurrency specifies the amount of routes that run in one thread. As of Nuxt >= v2.13 Nuxt comes with a crawler installed that will crawl your relative links and generate your dynamic links based on these links.
The issue seems to be the old cache located at /node_modules/.cache/pwa/icon
Nuxt doesn't generate new icons if the filenames are not changed so that is why the default icons are used. Especially if your new icon file is 'icon.png'.
You could go about this three ways:
Delete the cache at /node_modules/.cache/pwa/icon
before deploying but this only works with local/dev environment so this is out.
You could rename your file as the other comment suggested but you would have to rename it every time you change the file. So while this would work, it is still far from good, even for a hacky solution.
The third approach would be to delete that folder in your yarn/npm generate script. This would look something like this:
generate: 'rm -r /node_modules/.cache/pwa/icon && nuxt generate';
I had the same issue and the icons didn't get updated also on my local environment. For now I was able to fix it by adding
pwa: {
icon: {
fileName: 'app-icon.png',
},
},
to my nuxt.config.js and change the filename accordingly. But thats probably a little hacky.
I use Netlify for deployment and cleared the cache there but with no luck. Did you cleared your Runner Cache in Gitlab and then tried again?
This worked for me,
Delete the following:
Then do the following:
npm install
npm run generate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With