dcodegroup / vite-plugin-laravel-translations

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

Vite server can't launch #14

Closed JVT038 closed 1 year ago

JVT038 commented 1 year ago

When I launch Vite with this plugin, I see this error in the CLI and the server instantly stops.

error when starting dev server:
TypeError: Cannot read properties of undefined (reading 'sync')
    at buildTranslations (C:\folder\to\project\node_modules\vite-plugin-laravel-translations\dist\loader.js:55:34)
    at config (C:\folder\to\project\node_modules\vite-plugin-laravel-translations\dist\vite.js:33:65)
    at runConfigHook (file:///C:/\folder\to\project/node_modules/vite/dist/node/chunks/dep-79892de8.js:64005:31)
    at async resolveConfig (file:///C:/\folder\to\project/node_modules/vite/dist/node/chunks/dep-79892de8.js:63499:14)
    at async createServer (file:///C:/\folder\to\project/node_modules/vite/dist/node/chunks/dep-79892de8.js:62752:20)
    at async CAC.<anonymous> (file:///C:/\folder\to\project/node_modules/vite/dist/node/cli.js:734:24

This is my vite.config.js:

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

require('dotenv');
const path = require('path');

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/sass/app.scss',
                'resources/js/app.js',
            ],
            refresh: true,
        }),
        laravelTranslations({
            namespace: 'translation'
        })
    ],
    resolve: {
        alias: {
            '~/bootstrap-icons': path.resolve(__dirname, 'node_modules/bootstrap-icons/'),
        }
    },
    server: {
        hmr: {
            host: 'localhost',
        },
        port: process.env.VITE_SERVER_PORT
    }
});
immersedone commented 1 year ago

@JVT038 can you try install this particular branch to see if the problem still exists?

https://github.com/dcodegroup/vite-plugin-laravel-translations/tree/hotfix/patch-issue-with-windows-environments

PNPM: pnpm i -D "https://github.com/dcodegroup/vite-plugin-laravel-translations/tarball/hotfix/patch-issue-with-windows-environments"

NPM: npm i -D "https://github.com/dcodegroup/vite-plugin-laravel-translations/tarball/hotfix/patch-issue-with-windows-environments"

JVT038 commented 1 year ago

Thanks, that branch works!