-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Cannot read properties of undefined (reading 'VITE_LARAVEL_VUE_I18N_HAS_PHP') #49
Comments
Hey @andrey-helldar can you show me your |
My import vuetify from 'vite-plugin-vuetify'
import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
plugins: [
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false
}
}
}),
vuetify({
autoImport: true,
styles: 'sass'
})
],
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/assets/styles/_variables";`
}
}
}
}) |
I don't use Laravel in this project (this project only contains the frontend), so I didn't define the
// vite.config.ts
import { defineConfig } from 'vite'
import { resolve } from 'path'
import i18n from 'laravel-vue-i18n/dist/vite'
import vuetify from 'vite-plugin-vuetify'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
plugins: [
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false
}
}
}),
vuetify({
autoImport: true,
styles: 'sass'
}),
i18n()
],
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/assets/styles/_variables";`
}
}
}
}) The comment confused me:
|
got it, that is an interesting use case, for sure will need to dig in more. So you are just using the |
Yes https://github.com/volunteers-crm/web/tree/laravel-vue-i18n-2.x |
Can you try set on your "laravel-vue-i18n": "github:xiCO2k/laravel-vue-i18n" and then reinstall all the node dependences? Thanks for helping me debug this, |
really interesting case, will try to debug. Thanks for all the help @andrey-helldar. |
Next steps:
Now, it's works |
I was wrong. The problem is not solved :) I forgot that I just changed files 😅 https://github.com/volunteers-crm/web/blob/laravel-vue-i18n-2.x/vite.config.ts // vite.config.ts
import { defineConfig } from 'vite'
import { resolve } from 'path'
import i18n from 'laravel-vue-i18n/dist/vite'
import vuetify from 'vite-plugin-vuetify'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
},
plugins: [
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false
}
}
}),
vuetify({
autoImport: true,
styles: 'sass'
}),
i18n()
],
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "./src/assets/styles/_variables";`
}
}
}
}) https://github.com/volunteers-crm/web/blob/laravel-vue-i18n-2.x/src/utils/lang.ts // src/utils/lang.ts
import { Pinia } from 'pinia'
import { useSettingsStore } from '@/stores/settings'
export default (pinia: Pinia) => {
const lang = useSettingsStore(pinia).locale
const resolve = async (lang: string) => {
const files = import.meta.glob('../../lang/*.json')
return await files[`../../lang/${ lang }.json`]()
}
return { lang, resolve }
} https://github.com/volunteers-crm/web/blob/laravel-vue-i18n-2.x/.env.example#L3
And error) PS: my |
Thanks for the PR, can you try again, and let me know? |
By the way, so that the application does not load extra localizations during compilation, you can change the configuration: beforeimport { createApp } from 'vue'
import { i18nVue } from 'laravel-vue-i18n'
createApp()
.use(i18nVue, {
resolve: async lang => {
const langs = import.meta.glob('../../lang/*.json');
return await langs[`../../lang/${lang}.json`]();
}
})
.mount('#app'); afterimport { createApp } from 'vue'
import { i18nVue } from 'laravel-vue-i18n'
createApp()
.use(i18nVue, {
resolve: lang => import(`../../lang/${lang}.json`)
})
.mount('#app'); |
So after the merge you got not problem? |
When I wrote the code, there were no problems, but yesterday I could not check because npm and yarn gave an error installing dependencies when deleting the node_modules folder. I'll try again today.
|
Awesome, will tag it |
Result: not working
If we add output to the console, we see that the files are loaded:
Without the
VITE_LARAVEL_VUE_I18N_HAS_PHP
key, I also get the error:Version 1.4.4 worked perfectly.
The text was updated successfully, but these errors were encountered: