[Chartjs]-Using Chart.js with SvelteKit

5👍

Vite causes this. It’s both sveltekit’s greathest strength and weakest link.

Just add these lines to the config object within your svelte.config.js file and you should be fine :

const config = {
    kit: {
        // ...
        vite: {
            ssr:{
                noExternal: ['chart.js']
            }
        }
    }
    
};

3👍

addition to Tonton-blax awnser. The vite docs say ‘Prevent listed dependencies from being externalized for SSR. If true, no dependencies are externalized.’. So how i read it is that the dependency is accessible on the server side.

const config = {
    kit: {
        // ...
        vite: {
            ssr:{
                noExternal: ['chart.js']
            }
        }
    }
    
};

Leave a comment