Skip to content
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

How to make this work with Vite: getting "$ is not a function" #13

Open
jordanade opened this issue Mar 20, 2024 · 0 comments
Open

How to make this work with Vite: getting "$ is not a function" #13

jordanade opened this issue Mar 20, 2024 · 0 comments

Comments

@jordanade
Copy link

jordanade commented Mar 20, 2024

No matter how I configure my vite.config.js file, I get "$ is not a function" from livewire-select2's scripts.
I've tried:

import inject from '@rollup/plugin-inject';

export default defineConfig({
    plugins: [
        inject({
            $: 'jquery',
            jQuery: 'jquery',
        }),
        ...

and

    optimizeDeps: {
        include: ["jquery"],
    },

and

    build: {
        rollupOptions: {
            output: {
                // expose jQuery as a global variable
                globals: {
                    $: 'jquery',
                    jQuery: 'jquery',
                    'window.jQuery': 'jquery',
                }
            }
        }
    }

With my old webpack/mix setup I was able to make this work with:

mix.webpackConfig(webpack => {
    return {
        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery',
                'window.jQuery': 'jquery'
            }),
        ],
    };
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant