You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
 <inputtype="checkbox" /> [Extend `.wxt/tsconfig.json`](/guide/essentials/config/typescript.html#typescript-configuration) in your project's `tsconfig.json`<br />
21
+
 <inputtype="checkbox" /> [Extend `.wxt/tsconfig.json`](/guide/essentials/config/typescript#typescript-configuration) in your project's `tsconfig.json`<br />
22
22
 <inputtype="checkbox" /> Update/create `package.json` scripts to use `wxt` (don't forget about `postinstall`)<br />
23
23
 <inputtype="checkbox" /> Move entrypoints into `entrypoints/` directory<br />
24
24
 <inputtype="checkbox" /> Move assets into either the `assets/` or `public/` directories<br />
25
25
 <inputtype="checkbox" /> Move `manifest.json` content into `wxt.config.ts`<br />
26
26
 <inputtype="checkbox" /> Convert custom import syntax to be compatible with Vite<br />
27
27
 <inputtype="checkbox" /> Add a default export to JS entrypoints (`defineBackground`, `defineContentScript`, or `defineUnlistedScript`)<br />
28
28
 <inputtype="checkbox" /> Use the `browser` global instead of `chrome`<br />
29
-
 <inputtype="checkbox" /> Compare final `manifest.json` files, making sure permissions and host permissions are unchanged<br/>
29
+
 <inputtype="checkbox" /> ⚠️ Compare final `manifest.json` files, making sure permissions and host permissions are unchanged<br/>
30
30
:::warning
31
31
If your extension is already live on the Chrome Web Store, use [Google's update testing tool](https://github.com/GoogleChromeLabs/extension-update-testing-tool) to make sure no new permissions are being requested.
32
32
:::
@@ -48,7 +48,25 @@ Here's specific steps for other popular frameworks/build tools.
48
48
5. Convert Plasmo's custom import resolutions to Vite's
49
49
6. If importing remote code via a URL, add a `url:` prefix so it works with WXT
50
50
7. Replace your [Plasmo tags](https://docs.plasmo.com/framework/workflows/build#with-a-custom-tag) (`--tag`) with [WXT build modes](/guide/essentials/config/build-mode) (`--mode`)
51
-
8. Compare your output `manifest.json` files from before the migration to after the migration. They should have the same content. If not, tweak your entrypoints and config to get as close as possible.
51
+
8. ⚠️ Compare the old production manifest to `.output/*/manifest.json`. They should have the same content as before. If not, tweak your entrypoints and config until they are the same.
52
+
53
+
### CRXJS
54
+
55
+
If you used CRXJS's vite plugin, it's a simple refactor! The main difference between CRXJS and WXT is how the tools decide which entrypoints to build. CRXJS looks at your `manifest` (and vite config for "unlisted" entries), while WXT looks at files in the `entrypoints` directory.
56
+
57
+
To migrate:
58
+
59
+
1. Move all entrypoints into the `entrypoints` directory, refactoring to WXT's style (TS files have a default export).
60
+
2. Move [entrypoint specific options out of the manifest](/guide/essentials/entrypoints#defining-manifest-options) and into the entrypoint files themselves (like content script `matches` or `run_at`).
61
+
3. Move any other `manifest.json` options [into the `wxt.config.ts` file](/guide/essentials/config/manifest), like permissions.
62
+
4. For simplicity, you'll probably want to [disable auto-imports](/guide/essentials/config/auto-imports#disabling-auto-imports) at first (unless you were already using them via `unimport` or `unplugin-auto-imports`). If you like the feature, you can enable it later once you've finished the migration.
63
+
5. Update your `package.json` to include all of [WXT's suggested scripts (see step 4)](/guide/installation#from-scratch)
64
+
6. Specifically, make sure you add the `"postinstall": "wxt prepare"` script to your `package.json`.
65
+
7. Delete your `vite.config.ts` file. Move any plugins into the `wxt.config.ts` file. If you use a frontend framework, [install the relevant WXT module](/guide/essentials/frontend-frameworks).
66
+
8. Update your typescript project. [Extend WXT's generated config](/guide/essentials/config/typescript), and [add any path aliases to your `wxt.config.ts` file](/guide/essentials/config/typescript#tsconfig-paths).
67
+
9. ⚠️ Compare the old production manifest to `.output/*/manifest.json`. They should have the same content as before. If not, tweak your entrypoints and config until they are the same.
68
+
69
+
Here's an example migration: [GitHub Better Line Counts - CRXJS → WXT](https://github.com/aklinker1/github-better-line-counts/commit/39d766d2ba86866efefc2e9004af554ee434e2a8)
52
70
53
71
### `vite-plugin-web-extension`
54
72
@@ -60,4 +78,4 @@ Since you're already using Vite, it's a simple refactor.
60
78
4. Add `"postinstall": "wxt prepare"` script
61
79
5. Move the `manifest.json` into `wxt.config.ts`
62
80
6. Move any custom settings from `vite.config.ts` into `wxt.config.ts`'s
63
-
7. Compare `dist/manifest.json` to `.output/*/manifest.json`, they should have the same content as before. If not, tweak your entrypoints and config to get as close as possible.
81
+
7.⚠️ Compare the old production manifest to `.output/*/manifest.json`. They should have the same content as before. If not, tweak your entrypoints and config until they are the same.
0 commit comments