Skip to content

Commit

Permalink
docs: Update installation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Jul 21, 2023
1 parent 3107d27 commit aea866c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/get-started/build-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can build an extension for any combination of browser and manifest verison.
Separate build targets are written to their own output directories:

```
<root>
<rootDir>
└─ .output
├─ chrome-mv3
├─ firefox-mv2
Expand Down
21 changes: 15 additions & 6 deletions docs/get-started/configuration.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Configuration

WXT's behavior can be configured via the `wxt.config.ts` file. In this file, you can add Vite plugins, change the directory strucutre of your project, and provide permissions or other fields to the `<outdir>/manifest.json`.

However, since WXT is an opinionated framework, some things cannot be configured.
WXT's behavior can be configured via the `wxt.config.ts` file. In this file, you can add Vite plugins, change the directory strucutre of your project, and set fields on your `manifest.json`.

## Config File

Expand All @@ -17,21 +15,32 @@ export default defineConfig({
```

:::info
See the [API reference](/api.md) for a full list of options.
See the [Config reference](/config.md) for a full list of options.
:::

## Directory Config

WXT allows you to edit several directories to your liking:

- `root` (default: `process.cwd()`) - Root of the WXT project
- `srcDir` (default: `<root>`) - Location of all your source code
- `srcDir` (default: `<rootDir>`) - Location of all your source code
- `entrypointsDir` (default: `<srcDir>/entrypoints`) - Folder containing all the entrypoints.
- `publicDir` (default: `<srcDir>/public`) - Folder containing [public assets](/get-started/assets.md)

### Example

If you want a `src/` directory to contain all your source code, and you want to rename `entrypoints/` to `entries/`, your config would look like this:
You want a `src/` directory to contain all your source code, and you want to rename `entrypoints/` &rarr; `entries/`:

```
<rootDir>
├─ src/
│ └─ entries/
│ ├─ background.ts
│ └─ ...
└─ wxt.config.ts
```

Your config would look like this:

```ts
import { defineConfig } from 'wxt';
Expand Down
2 changes: 1 addition & 1 deletion docs/get-started/entrypoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In WXT, entrypoints are defined by adding a file to the `entrypoints/` directory
For example, a project that looks like this:

```
<root>
<rootDir>
├─ entrypoints/
│ ├─ background.ts
│ ├─ content.ts
Expand Down
15 changes: 13 additions & 2 deletions docs/get-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,20 @@ pnpm dev
The dev command will build the extension for development, open the browser, and reload the different parts of the extension when you save changes.
:::

:::details Development Manifest
When running the dev command, WXT will make several changes to your `manifest.json` to improve your development experience:

- If missing, add a background script/service worker to enable fast reloads
- Add serveral `permissions` and `host_permissions` to enable HMR and fast reloads
- Modify the CSP to allow connections with the dev server
- Remove `content_scripts` and register them at runtime so they can be easily reloaded when you save a file

If you're an experienced web extension developer and think the dev manifest looks wrong, this is why. Run a production build with `wxt build` to see the unmodified `manifest.json`.
:::

## Next Steps

You're ready to build a out your web extension!
You're ready to build your web extension!

- Learn how to [add entrypoints](./entrypoints.md) like the popup, background, or content scripts
- Learn how to [add entrypoints](./entrypoints.md) like the popup, options page, or content scripts
- [Configure WXT](./configuration.md) by creating a `wxt.config.ts` file
4 changes: 2 additions & 2 deletions src/core/utils/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export async function generateMainfest(

if (manifest.name == null)
throw Error(
"Manifest 'name' is missing. Either:\n1. Set the name in your <root>/package.json\n2. Set a name via the manifest option in your wxt.config.ts",
"Manifest 'name' is missing. Either:\n1. Set the name in your <rootDir>/package.json\n2. Set a name via the manifest option in your wxt.config.ts",
);
if (manifest.version == null) {
throw Error(
"Manifest 'version' is missing. Either:\n1. Add a version in your <root>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts",
"Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts",
);
}

Expand Down

0 comments on commit aea866c

Please sign in to comment.