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

lara28580's avatar

Compile tailwind css in vue component

I want tailwind css to compile in my vue components but somehow I can't get that to work. What I tried so far

Added the components to the vite config options

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

Any ideas?

Best

0 likes
6 replies
lara28580's avatar

@Sinnbeck No it is not a spa.

app.js

import { createApp } from 'vue/dist/vue.esm-bundler'
import VueInstantSearch from 'vue-instantsearch/vue3/es';
import MySearch from './components/MySearch.vue'

const app = createApp(VueInstantSearch)

app.component('my-search', MySearch)

app.mount('#app')

app.css

@import '/node_modules/instantsearch.css/themes/algolia-min.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
Sinnbeck's avatar

@SmokeTM then just load the css file in @vite() in your layout

@vite(['resources/css/app.css', 'resources/js/app.js',])
export default defineConfig({
    plugins: [
        vue(),
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
                
            ],
            refresh: true,
        }),
    ],
});
1 like
lara28580's avatar

@Sinnbeck Did that already but the css classes are not compiled in my vue components.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@SmokeTM did you tell tailwind to look in those? In the content array in the tailwind config

1 like

Please or to participate in this conversation.