F
Filament4mo ago
Prodex

Include JS Asset: "Identifier X has already been declared"

If I include JavaScript like the docs say, it doesn't bundle it through vite, so this doesn't work:
FilamentAsset::register([
Js::make('sentry', __DIR__ . '/../../resources/js/sentry.js'),
]);
FilamentAsset::register([
Js::make('sentry', __DIR__ . '/../../resources/js/sentry.js'),
]);
If I use the Vite facade it does load the correct file, but I get "Identifier X has already been declared", because vite doesn't know, that there are other assets as well.
FilamentAsset::register([
Js::make('sentry', Vite::asset('resources/js/sentry.js')),
]);
FilamentAsset::register([
Js::make('sentry', Vite::asset('resources/js/sentry.js')),
]);
How can I avoid this problem?
2 Replies
Lara Zeus
Lara Zeus4mo ago
why not using the compiled version
FilamentAsset::register([
Js::make('sentry', asset('js/sentry.js')),
]);
FilamentAsset::register([
Js::make('sentry', asset('js/sentry.js')),
]);
Prodex
Prodex4mo ago
that's not working, how should the compiled version hash be resolved?