Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a short vite description #3001

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,64 @@ You may also choose to import the components on the fly in a `.vue` file.
</script>
```

## 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.
Expand Down