Skip to content

Commit

Permalink
Add Vite config instruction (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper authored Jan 29, 2024
1 parent d7dbdff commit b6d0371
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/pages/getting-started/astro.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ Install Lucia using your package manager of your choice. While not strictly nece
npm install lucia oslo
```

## Update Vite

If you've installed `oslo`, add `oslo` to `vite.optimizeDeps.exclude`.

```ts
// astro.config.mjs
import { defineConfig } from "vite";

export default defineConfig({
// ...
optimizeDeps: {
exclude: ["oslo"]
}
});
```

## Initialize Lucia

Import `Lucia` and initialize it with your adapter. Refer to the [Database](/database) page to learn how to set up your database and initialize the adapter. Make sure to configure the `sessionCookie` option and register your `Lucia` instance type
Expand Down
28 changes: 28 additions & 0 deletions docs/pages/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,31 @@ globalThis.crypto = webcrypto as Crypto;
```
node --experimental-web-crypto index.js
```

## Update bundler configuration

This is only required if you're using `oslo/password`.

### Vite

This is not required if you're Nuxt, SolidStart, or SvelteKit.

```ts
import { defineConfig } from "vite";

export default defineConfig({
// ...
optimizeDeps: {
exclude: ["oslo"]
}
});
```

### Webpack

```ts
module.exports = {
// ...
externals: ["@node-rs/argon2", "@node-rs/bcrypt"]
};
```
22 changes: 20 additions & 2 deletions docs/pages/upgrade-v3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ Refer to these guides:
- [Upgrade OAuth setup to v3](/upgrade-v3/oauth)
- [Upgrade Password-based auth to v3](/upgrade-v3/password)

## Next.js
## Framework specific configuration

If you installed Oslo, mark its dependencies as external to prevent it from getting bundled. This is only required when using the `oslo/password` module.
If you installed Oslo, you must prevent `oslo` from getting bundled. This is only required when using the `oslo/password` module.

### Next.js

```ts
// next.config.ts
Expand All @@ -191,3 +193,19 @@ const nextConfig = {
}
};
```

### Vite

This is not required when using Nuxt, SolidStart, and SvelteKit. This is required for Astro and Remix (currently debugging the issue).

```ts
// astro.config.mjs
import { defineConfig } from "vite";

export default defineConfig({
// ...
optimizeDeps: {
exclude: ["oslo"]
}
});
```

0 comments on commit b6d0371

Please sign in to comment.