dcodegroup / vite-plugin-laravel-translations

Vite Plugin to convert Laravel Translations into a global variable for use within front-end frameworks.
5 stars 4 forks source link

TypeError: laravelTranslations is not a function #17

Closed Temepest74 closed 3 weeks ago

Temepest74 commented 1 year ago

I get this error when building my assets

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import laravelTranslations from 'vite-plugin-laravel-translations';

export default defineConfig({
    plugins: [
        laravel({
            input: ["resources/css/app.css", "resources/js/app.js"],
            refresh: true,
        }),
        laravelTranslations({
            includeJson: false,
            namespace: false,
        }),
    ],
    server: {
        hmr: {
            host: "localhost",
        },
    },
});
Temepest74 commented 1 year ago

Update: no error if I do

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import laravelTranslations from "vite-plugin-laravel-translations";

export default defineConfig({
    plugins: [
        laravel({
            input: ["resources/css/app.css", "resources/js/app.js"],
            refresh: true,
        }),
        laravelTranslations.default({
            includeJson: false,
            namespace: false,
        }),
    ],
    server: {
        hmr: {
            host: "localhost",
        },
    },
});
lionslair commented 8 months ago

Cool thanks. @immersedone is there a way we can not need the .default?

adesege commented 1 month ago

You can use https://www.npmjs.com/package/vite-plugin-laravel-i18next which has support for Typescript and supports all the localization features of Laravel.