diff --git a/docs/handling-uploads-with-media-library-pro/handling-uploads-with-vue.md b/docs/handling-uploads-with-media-library-pro/handling-uploads-with-vue.md index 15471cb25..f468b823c 100644 --- a/docs/handling-uploads-with-media-library-pro/handling-uploads-with-vue.md +++ b/docs/handling-uploads-with-media-library-pro/handling-uploads-with-vue.md @@ -177,6 +177,64 @@ You may also choose to import the components on the fly in a `.vue` file. ``` +## Vite +If you are using vite, you need to import an alias to the `vite.config.js` and some little changes to your Vue component. + +```diff +// vite.config.js + +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; +import vue from '@vitejs/plugin-vue'; + +export default defineConfig({ + ... + resolve: { + alias: { + '@': '/resources/js', ++ 'spatie-media-lib-pro': '/vendor/spatie/laravel-medialibrary-pro/resources/js', + }, + }, +}); +``` + +**Component changes Vue2** + +```diff +... +- import { MediaLibraryAttachment } from "media-library-pro-vue2-attachment"; ++ import { MediaLibraryAttachment } from "spatie-media-lib-pro/media-library-pro-vue2-attachment"; +- import { MediaLibraryCollection } from "media-library-pro-vue2-collection"; ++ import { MediaLibraryCollection } from "spatie-media-lib-pro/media-library-pro-vue2-collection"; +... +``` + +**Component changes Vue3** + +```diff +... +- import { MediaLibraryAttachment } from "media-library-pro-vue3-attachment"; ++ import { MediaLibraryAttachment } from "spatie-media-lib-pro/media-library-pro-vue3-attachment"; +- import { MediaLibraryCollection } from "media-library-pro-vue3-collection"; ++ import { MediaLibraryCollection } from "spatie-media-lib-pro/media-library-pro-vue3-collection"; +... +``` + +**CSS Import for SPA use** + +If you are using a SPA you can import the CSS into `app.js` like this: + +```diff +// resources/js/app.js +import './bootstrap'; +import '../css/app.css'; ++import 'spatie-media-lib-pro/media-library-pro-styles/src/styles.css'; +... +``` + +If you want to import the CSS into `app.css` you can still use the import mentioned in [Customizing CSS](./customizing-css). + + ## Your first components The most basic components have a `name` prop. This name will be used to identify the media when it's uploaded to the server.