How do I import a 2nd CSS framework (prefixed) into my Vite-based Vue 3 project (1st framework being TailwindCSS)

Viewed 18

So I have a default Laravel app working with Vue 3 and assets configured by Vite, TailwindCSS and TailwindUI installed. This all works fine.

I understand to have another CSS framework, I need to prefix it to avoid clashes. According to these instructions, I need to add the following line: (after installing via npm):

import PrimeVue from 'primevue/config'; //I have included this in app.js

as well as reference these styles:

primevue/resources/themes/saga-blue/theme.css
primevue/resources/primevue.min.css  
primeicons/primeicons.css

How exactly do I reference these css files with a prefix so as to avoid clashes?

My postcss.config.js file currently looks like this:

module.exports = {
  plugins: {
      tailwindcss: {},
      autoprefixer: {},
  },
};

My app.js looks like this:

import './bootstrap';
import '../css/app.css';

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';

/* added by me*/ import  PrimeVue  from 'primevue/config';
/* added by me*/ import InputMask from 'primevue/inputmask';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
        .use(plugin)
        .use(ZiggyVue, Ziggy)
        .use(PrimeVue)

 /*added by me*/ .component('InputMask', InputMask)

        .mount(el);
    },
});

InertiaProgress.init({ color: '#4B5563' });
0 Answers
Related