Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pratikbhujel's avatar

Guidance on Integrating Templates in Laravel Using NPM and Webpack

I am seeking assistance with integrating the Bootstrap AdminLTE template or another backend template. Additionally, I'd like to incorporate a different template for the frontend, utilizing Bootstrap and jQuery with separate CSS and JS files. Specifically, I aim to include only admin.css and admin.js in my layout. Should I opt for Vite, or is Webpack a better choice? I appreciate any guidance through this process.

Thank you.

0 likes
3 replies
gych's avatar

You can use either Vite or Webpack for that, personally I would go with Vite because its much faster and also the default for Laravel now.

But if you prefer to work with Webpack that's still possible, in the end its personal preference.

pratikbhujel's avatar

@gych, thanks for the reply. I'm aiming to integrate the Bootstrap AdminLTE template or another suitable backend template. For the frontend, I'd like to incorporate a different template using Bootstrap and jQuery with separate CSS and JS files, including only admin.css and admin.js in my layout.

Additionally, I'm interested in integrating DataTable, Select2, and other Twubowg features. Could you provide step-by-step guidance or point me in the right direction for this comprehensive process?

Thank you.

gych's avatar
gych
Best Answer
Level 29

@pratikbhujel

  • Import your js files directly to bootstrap.js, by default bootstrap.js should already be imported in app.js You can also import the files directly to app.js, but I prefer to import those files in bootstrap.js for a cleaner setup

  • If you look in the vite config you'll see that app.js is already added to the build input

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

For css you can import your css files in app.css because as you can see in the above example by default app.css is also already added to the input.

If you want you can also add files directly to the input instead of adding them via bootstrap.js/app.js or app.css files. As you can see in the example below, I added admin.css.

            input: [
                'resources/css/app.css',
				'resources/css/admin.css',
                'resources/js/app.js',
            ],

But personally I rarely do that, I mostly add files to app.css and bootstrap.js/app.js

1 like

Please or to participate in this conversation.