Comments (15)
@userquin @danielroe minimal reproduction is here, but stackblitz can't exec sharp, so I think should download this project and run at local
https://stackblitz.com/edit/reproduce-vite-pwa-nuxt-assets-custom-src-gwjm7u?file=README.md
from nuxt.
Nuxt resolves the public directory like this: resolve(nuxt.options.srcDir, nuxt.options.dir.public)
. dir.public
is public
in v4 but will be a fully resolved directory in v4, defaulting to resolve(nuxt.options.rootDir, 'public')
.
from nuxt.
Nuxt resolves the public directory like this: resolve(nuxt.options.srcDir, nuxt.options.dir.public). dir.public is public in v4 but will be a fully resolved directory in v4, defaulting to resolve(nuxt.options.rootDir, 'public').
So... nuxt image not yet compatible with v4 layout
from nuxt.
resolve(nuxt.options.srcDir, options.dir)
should correctly resolve to resolve(nuxt.options.rootDir, 'public')
in this case.
from nuxt.
Nuxt 3.12.0 (nightly) also failing when building and generating dts pwa icons (weird, in dev works)
/cc @danielroe maybe some paths in dev different from build/prepare commands
from nuxt.
@aa900031 can you provide minimal reproduction?
from nuxt.
Daniel, in Nuxt 3.12 now we have 2 Vite roots, server (root folder) and client (now it is app folder) and so we need to change the logic: since we've the image relative to root folder we cannot use the same logic fro server and client.
Moving pwa-assets.config file inside app works in dev but not generating pwa icons on build: pwa icons types in dts also missing.
EDIT: adding pwa-assets-config with relative image works, but we need 2 pwa assets config files.
from nuxt.
@aa900031 we need to review the logic in vite pwa plugin, we'll need to add some hooks to resolve pwa assets configuration and pwa image, by default should work as it is right now (add resolve config and resolve pwa image).
In the meantime use default nuxt layout or switch to PWA Assets Generator CLI, sorry.
from nuxt.
@userquin Thanks for your reply, I'll use CLI to handle it for now
from nuxt.
@aa900031 I guess I've found the problem, testing with your reproduction, maybe we don't need to change pwa plugin.
from nuxt.
With the new version I'm going to release (0.8.0), you will need to move pwa-assets.config.ts
inside src
folder and:
- configure public dir properly
// nuxt.config.ts
import { resolve } from 'node:path'
...
export default defineNuxtConfig({
nitro: {
publicAssets: [{ dir: resolve(process.cwd(), 'src/public') }]
},
dir: {
public: 'src/public',
},
- or move public folder to root (like new v4 layout, using
app
insteadsrc
), you also need to change image name inpwa-assets.config.ts
:
// src/pwa-assets.config.ts
export default defineConfig({
...
images: '../public/favicon.svg',
})
from nuxt.
I think change dir.public is not a good idea, that will be have compatibility for other modules.
let me find some modules later
from nuxt.
If use nuxt/image modules and set dir.public like your guide that will not working
because nuxt/image resolve public dir with srcDir: https://github.com/nuxt/image/blob/3a98a685746b5be2188ddf59d091a4f3e525067b/src/module.ts#L60
from nuxt.
If nuxt/image resolves the public path to src/public
in the context of setting srcDir: 'src'
Continuing with the previous context, I added the setting dir.public: 'src/public'
suggested by @userquin, then the public path I will get in nuxt/image will be src/src/public
, right? Such a result should be unexpected
The above versions are all in Nuxt 3
from nuxt.
Continuing with the previous context, I added the setting dir.public: 'src/public' suggested by @userquin, then the public path I will get in nuxt/image will be src/src/public, right? Such a result should be unexpected
I need to review the code, it will take more time since I need to rewrite the pwa plugin logic, in the meantime use the CLI, sorry again.
The above versions are all in Nuxt 3
Yes, but we're talking about a breaking change in Nuxt 3.12, you can try using nuxt 3.12 (npm:nuxt-nightly@latest
) moving public folder to root, both nuxt image and pwa will work (use my previous 2).
from nuxt.
Related Issues (20)
- vite-pwa/nuxt not working on ios
- Module does nothing ? (EDIT: No Firefox support ?) HOT 9
- Nuxt3 + PWA warnings in terminal HOT 6
- cant use npm run build
- I can't get 'start_url' to work for me
- showInstallPrompt not being called HOT 1
- Uncaught ReferenceError: __NUXT_ASYNC_CONTEXT__ is not defined HOT 7
- Service Worker "import sentry-release-injection" error when loading page HOT 19
- @vite-pwa/nuxt and vue-tsc conflict HOT 4
- API Request URLs Open in New Tab Redirect to 404 Page HOT 2
- Default value of navigateFallbackAllowlist
- offline mode: when I navigate to another route, it shows nothing, but when I refresh then it shows the page from cache HOT 7
- Vite-pwa/nuxt not caching pages on a client-side rendered app HOT 3
- How to handle i18n ? HOT 1
- assets generation not working with nuxt 4 without this workaround HOT 2
- Can only visit url with trailing slash once
- Nuxt 3.12.3 composable types break when @vite-pwa/nuxt is installed HOT 20
- How can i make a dialog HOT 3
- @vite-pwa/assets-generator and @vite-pwa/nuxt give error only in production, related to workbox HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuxt.