xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
621 stars 51 forks source link

i18n is not a function #125

Closed nmedelmehdi closed 1 year ago

nmedelmehdi commented 1 year ago

Hello

I installed according to the documentation the library on my Laravel 10/Inertia/VueJS3 project.

I have a problem loading the php language files, indeed to do so I need to use i18n() in "vite.config.js".

here is my configuration:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import i18n from 'laravel-vue-i18n/vite';
export default defineConfig({
    plugins: [
        laravel({
            input: 'resources/js/app.js',
            refresh: true,
        }),
        view({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
        i18n(),
    ],
});

As soon as I include i18n in vite.config.js, vite crach displays this error:

> dev
> vite

failed to load config from /var/www/html/vite.config.js
error when starting dev server:
TypeError: i18n is not a function
    at file:///var/www/html/vite.config.js.timestamp-1683813849891-8e58688ed0eb.mjs:20:5
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

I specify that everything works correctly except this error related to the import of the files

If anyone can help or refer me? Thank you very much!

milorojas commented 1 year ago

same error on a fresh new laravel app (Breeze/Vue)

daniser commented 1 year ago

Remove "type": "module" from your package.json file and try again. Does it help?

milorojas commented 1 year ago

Yes it was that, thanks, after that i have to update postcss.config.js from export default { plugins: { tailwindcss: {}, autoprefixer: {}, }, };

to

module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };

Thanks

milorojas commented 1 year ago

This is related to the recent change on https://github.com/laravel/breeze/pull/246

daniser commented 1 year ago

This is related to the recent change on laravel/breeze#246

Yup, I think this library needs ESM build too to catch up with Laravel trends. I'll look into that when I've spare time.

xiCO2k commented 1 year ago

Good case, that would be great @daniser 💪

nmedelmehdi commented 1 year ago

thnaks @daniser ! perfect !