Manage assets between dev & prod with vitejs #13406
Unanswered
max13fr
asked this question in
CLI - SSR mode
Replies: 1 comment
-
Hello, I found a partial solution to the second try : the client need to use index.html instead of client-entry.js (but the SSR server need to use server-entry.js). So I changed my quasar.conf.js to : extendViteConf(viteConf, { isClient }) {
viteConf.build.rollupOptions = {
'external': function(id) {
return id.startsWith('/v2/assets/');
},
'input': isClient ? 'index.html' : '.quasar/server-entry.js',
};
}, Now the build is working 🥳 but I got an error when I'm trying to run the server 😞 : (cd /opt/quasar/dist/ssr && npm run start)
I don't understand why the image is managed as module instead of just an external link :/ Max |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm using the new CLI with vitejs, it's really fast thanks for your hard work !
I just have an issue with assets when I'm trying to build my projet.
I tried a lot of solutions without any success unfortunatelly.
For context, I'm using last version of quasar 2.6.6 and @quasar/app-vite 1.0.0-beta.14.
First try : using root relative urls
According to the documentation (https://quasar.dev/quasar-cli-vite/handling-assets), "root-relative URLs (e.g. /logo.png – where ‘/’ is your publicPath) or logo.png are not processed at all".
So I tried this :
With this following quasar.config.js (all /v2/* urls are forward to quasar, but we also accept root url without v2 with nginx specific rules) :
It's working with
quasar dev -m ssr
but when I'm tryingquasar build -m ssr
, I got the following error :Without the mode SSR (so in SPA mode) the build is working fine.
Second try : using root relative urls with rollupOptions.external
As the assets is still processed, I tried to manually override rollup options to avoid processing url starting by "/v2/assets/".
So I added the following to quasar.config.js :
The input is required to I inspected quasar code and it's seems to use .quasar/client-entry.js as input.
Now the building seems to working fine but I got another error after (don't know why as the config seems to be the same used by default in quasar) :
Third try : using /src/assets/*
I tried to put all my assets in /src/assets/ then change my link to :
Now it's working when I'm building, but in dev mode the assets are not found as vitejs isn't rewriting the link as in the build : the browser is looking for https://mydomain.name/src/assets/iphone.png
How do you manage the compatibility between dev & build modes ?
Thanks in advance,
Max
Beta Was this translation helpful? Give feedback.
All reactions