Skip to content

Commit

Permalink
Update vite docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Oct 4, 2024
1 parent a44d4d5 commit 83caf62
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/guide/essentials/config/auto-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({

By default, WXT automatically setups up auto-imports for all of it's own APIs:

- [`browser`](/api/reference/wxt/browser/variables/browser) from `wxt/browser`, a small wrapper around `webextension-polyfill`
- [`browser`](/api/reference/wxt/browser/variables/browser) from `wxt/browser`
- [`defineContentScript`](/api/reference/wxt/sandbox/functions/defineContentScript) from `wxt/sandbox`
- [`defineBackground`](/api/reference/wxt/sandbox/functions/defineBackground) from `wxt/sandbox`
- [`defineUnlistedScript`](/api/reference/wxt/sandbox/functions/defineUnlistedScript) from `wxt/sandbox`
Expand Down
27 changes: 24 additions & 3 deletions docs/guide/essentials/config/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,38 @@ To add a plugin, install the NPM package and add it to the Vite config:
```ts
// wxt.config.ts
import { defineConfig } from 'wxt';
import removeConsole from 'vite-plugin-remove-console';
import VueRouter from 'unplugin-vue-router/vite';

export default defineConfig({
vite: () => ({
plugins: [removeConsole({ includes: ['log'] })],
plugins: [
VueRouter({
/* ... */
}),
],
}),
});
```

:::warning
Due to the way WXT orchestrates Vite builds, some plugins may not work as expected. Search [GitHub issues](https://github.com/wxt-dev/wxt/issues?q=is%3Aissue+label%3A%22vite+plugin%22) if you run into issues with a specific plugin.
Due to the way WXT orchestrates Vite builds, some plugins may not work as expected. For example, `vite-plugin-remove-console` normally only runs when you build for production (`vite build`). However, WXT uses a combination of dev server and builds during development, so you need to manually tell it when to run:

```ts
// wxt.config.ts
import { defineConfig } from 'wxt';
import removeConsole from 'vite-plugin-remove-console';

export default defineConfig({
vite: (configEnv) => ({
plugins:
configEnv.mode === 'production'
? [removeConsole({ includes: ['log'] })]
: [],
}),
});
```

Search [GitHub issues](https://github.com/wxt-dev/wxt/issues?q=is%3Aissue+label%3A%22vite+plugin%22) if you run into issues with a specific plugin.

If an issue doesn't exist for your plugin, [open a new one](https://github.com/wxt-dev/wxt/issues/new/choose).
:::

0 comments on commit 83caf62

Please sign in to comment.