-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import Quasar language packs in Vite #12911
Comments
Hi @Maggie0002! 👋 It looks like you provided an invalid or unsupported reproduction URL. Without a proper reproduction, your issue will have to get closed. Thank you for your collaboration. 👏 |
First of all, for anyone reading, this is not a Quasar issue. |
Long story short (extract from my additions to the docs below). The examples are with boot files, but I think you can infer how to use in vue files also.
// -- With @quasar/app-vite --
import { Quasar } from 'quasar'
// relative path to your node_modules/quasar/..
// change to YOUR path
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs')
// or just a select few (example below with only DE and FR):
// import.meta.glob('../../node_modules/quasar/lang/(de|fr).mjs')
export default async () => {
const langIso = 'de' // ... some logic to determine it (use Cookies Plugin?)
try {
langList[ `../../node_modules/quasar/lang/${ langIso }.mjs` ]().then(lang => {
Quasar.lang.set(lang.default)
})
}
catch (err) {
// Requested Quasar Language Pack does not exist,
// let's not break the app, so catching error
}
}
|
Looks good, an adapted version using the same method seems to be working for me. Thanks. |
What happened?
In Webpack, I would use the following to import languages from the quasar node_modules folder are per the Quasar docs:
It looks like
import.meta.glob
is the best proposed alternative but it isn't compatible with node_module imports: vitejs/vite#5728.At the moment there doesn't seem to be a good way to import these languages from the node_modules folder other than by either symlinking or copying them across manually and storing them in the src/ folder somewhere: vitejs/vite#5728 (comment)
Ideally it would be useful to establish a 'best practice' for overcoming this issue in Quasar projects in Vite.
What did you expect to happen?
Be able to import the Quasar language files from node_modules so changes are pulled in to the app on a update automatically.
Reproduction URL
Not applicable
How to reproduce?
N/A
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)
Platforms/Browsers
No response
Quasar info output
No response
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: