Hi,
I don't understand how to setup Astro (https://astro.build/) to use last PrimeVue's version.
has anyone ever configured it?
Thank you,
Amibel
How setup PrimeVue with Astro
Hi
Hi do not know whether it is the recommended way, but here is how I got it running:
1. Install primevue & primeicons
2. in your astro.config.mjs add an _app.ts entrypoint to the vue integrations
2. create a /src/_app.ts file and import some components (source)
2. Import the CSS files ( I did that in my Layout.astro file)
3. Import the Prime-Component in you vue component
4. now you should be able to use it
Hi do not know whether it is the recommended way, but here is how I got it running:
1. Install primevue & primeicons
Code: Select all
npm install primevue primeicons --save
Code: Select all
export default defineConfig({
....
integrations: [ vue({
appEntrypoint: "/src/_app.ts",
reactivityTransform: true
})]
});
Code: Select all
import type { App } from "vue";
import Button from "primevue/button"
import Menu from "primevue/menu"
import PrimeVue from "primevue/config"
import { RouterLink } from "vue-router";
const components = {
Button,
Menu,
RouterLink
}
export default (app: App) => {
app.use(PrimeVue)
for (const [key, value] of Object.entries(components)) {
app.component(key, value)
}
}
2. Import the CSS files ( I did that in my Layout.astro file)
Code: Select all
import 'primevue/resources/primevue.min.css';
import 'primeicons/primeicons.css';
import 'primevue/resources/themes/lara-light-teal/theme.css';
Code: Select all
import Button from 'primevue/button';
Code: Select all
<Button label="Click me" />
-
- Posts: 61
- Joined: 06 Sep 2022, 08:59
Hi,5kyn3t wrote: ↑26 Feb 2023, 22:44Hi
Hi do not know whether it is the recommended way, but here is how I got it running:
1. Install primevue & primeicons2. in your astro.config.mjs add an _app.ts entrypoint to the vue integrationsCode: Select all
npm install primevue primeicons --save
2. create a /src/_app.ts file and import some components (source)Code: Select all
export default defineConfig({ .... integrations: [ vue({ appEntrypoint: "/src/_app.ts", reactivityTransform: true })] });
Code: Select all
import type { App } from "vue"; import Button from "primevue/button" import Menu from "primevue/menu" import PrimeVue from "primevue/config" import { RouterLink } from "vue-router"; const components = { Button, Menu, RouterLink } export default (app: App) => { app.use(PrimeVue) for (const [key, value] of Object.entries(components)) { app.component(key, value) } }
2. Import the CSS files ( I did that in my Layout.astro file)3. Import the Prime-Component in you vue componentCode: Select all
import 'primevue/resources/primevue.min.css'; import 'primeicons/primeicons.css'; import 'primevue/resources/themes/lara-light-teal/theme.css';
4. now you should be able to use itCode: Select all
import Button from 'primevue/button';
Code: Select all
<Button label="Click me" />
I'm planning to create a sample repo for using PrimeVue with Astro. I will also benefit from this answer. If there are deficiencies in the repo, I would be very happy if you contribute. Thank you very much.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests