Ashraam's avatar
Level 41

Vite error while building assets

Hi everyone,

I'm building a website based on a template, so I've put the template and all files (js, css, img) related to it into the resources folder.

The template folder contains sub-folders like css, js, img, vendors and in my views I access those assets like this

Vite::asset('resources/template/img/logo-blanc.svg')

It works perfectly.

My vite config is:

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

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/template'
            ],
            refresh: true,
        }),
    ],
});

When I use the command npm run dev it works perfectly bu when I try to build the assets with npm run build it fails and the error is:

vite v5.1.4 building for production... ✓ 0 modules transformed. x Build failed in 4ms error during build: RollupError: Could not resolve entry module "resources/template". at getRollupEror (file:///Users/romainbertolucci/Sites/camping-colomba/node_modules/rollup/dist/es/shared/parseAst.js:375:41) at error (file:///Users/romainbertolucci/Sites/camping-colomba/node_modules/rollup/dist/es/shared/parseAst.js:372:42) at ModuleLoader.loadEntryModule (file:///Users/romainbertolucci/Sites/camping-colomba/node_modules/rollup/dist/es/shared/node-entry.js:18928:20) at async Promise.all (index 0)

How can I solve that error ?

Thank

0 likes
2 replies
martinbean's avatar
Level 80

@ashraam resources/template is a directory. You need to add file paths to entry points in the input array, such as your main JavaScript file, your main SCSS file, etc.

1 like

Please or to participate in this conversation.