Giter Club home page Giter Club logo

Comments (4)

userquin avatar userquin commented on June 10, 2024 1

@logotip4ik I'll review latest changes in Nuxt, it is weird, mode should be production and injectManifest should minify the sw (the pwa plugin includes process.env.NODE_ENV="production" via Vite define option in the custom build): https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/modules.ts#L95

from nuxt.

userquin avatar userquin commented on June 10, 2024 1

@logotip4ik found the problem:

  • by default Vite will use esbuild to minify, since we're using a custom Vite build to build the service worker, Vite will use esbuild since pwa plugin will not provide/change the build.minify option
  • vite-plugin-pwa is using es as default Rollup format to build the service worker, but Vite will not remove empty spaces https://vitejs.dev/config/build-options.html#build-minify:

    Note the build.minify option does not minify whitespaces when using the 'es' format in lib mode, as it removes pure annotations and breaks tree-shaking.

You can change the format using iife, the service worker is minified but the code generated is wrong and will not work.

You can check it here in this SB fork : https://stackblitz.com/edit/nuxt-starter-al3pyt?file=nuxt.config.ts.
If you run yarn build the output will be on server/public folder, I've changed nitro output.dir and there is an issue on nitro about custom output (also tried with terser plugin with no luck).

from nuxt.

userquin avatar userquin commented on June 10, 2024

anyway, your sw has errors: missing race and debug variables and error in L55

from nuxt.

logotip4ik avatar logotip4ik commented on June 10, 2024

anyway, your sw has errors: missing race and debug variables and error in L55

I thought that they would be somehow inlined at the build time 😅. I took this example from vite-pwa website (https://vite-pwa-org.netlify.app/workbox/inject-manifest.html#network-first-strategy). Should i open pr to fix this ?

from nuxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.