Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35f6d28977 | |||
| 43fcbec0eb | |||
| a0d56b4d27 | |||
| 38ccb6ace6 | |||
| aaf75f1de1 | |||
| 21e8ca0a2c |
@@ -1,28 +1,59 @@
|
|||||||
# Frontend Frameworks
|
# Frontend Frameworks
|
||||||
|
|
||||||
WXT supports all frontend frameworks with a Vite plugin:
|
## Built-in Modules
|
||||||
|
|
||||||
- `@vitejs/plugin-vue`
|
WXT has preconfigured modules for 4 frameworks:
|
||||||
- `@vitejs/plugin-react`
|
|
||||||
- `@vitejs/plugin-react-swc`
|
|
||||||
- And more!
|
|
||||||
|
|
||||||
Just add the vite plugin to your config and you're good to go! Use the framework in HTML pages or content scripts, it will just work 👍
|
- [`@wxt-dev/module-react`](https://github.com/wxt-dev/wxt/tree/main/packages/module-react)
|
||||||
|
- [`@wxt-dev/module-vue`](https://github.com/wxt-dev/wxt/tree/main/packages/module-vue)
|
||||||
|
- [`@wxt-dev/module-svelte`](https://github.com/wxt-dev/wxt/tree/main/packages/module-svelte)
|
||||||
|
- [`@wxt-dev/module-solid`](https://github.com/wxt-dev/wxt/tree/main/packages/module-solid)
|
||||||
|
|
||||||
|
Install the module for your framework, then add it to your config:
|
||||||
|
|
||||||
:::code-group
|
:::code-group
|
||||||
|
|
||||||
```ts [Vue]
|
```ts [React]
|
||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import vue from '@vitejs/plugin-vue';
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
vite: () => ({
|
modules: ['@wxt-dev/module-react'],
|
||||||
plugins: [vue()],
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
```ts [React]
|
```ts [Vue]
|
||||||
|
import { defineConfig } from 'wxt';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
modules: ['@wxt-dev/module-vue'],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts [Svelte]
|
||||||
|
import { defineConfig } from 'wxt';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
modules: ['@wxt-dev/module-svelte'],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts [Solid]
|
||||||
|
import { defineConfig } from 'wxt';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
modules: ['@wxt-dev/module-solid'],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
## Adding Vite Plugins
|
||||||
|
|
||||||
|
If your framework doesn't have an official WXT module, no worries! WXT supports any framework with a Vite plugin.
|
||||||
|
|
||||||
|
Just add the Vite plugin to your config and you're good to go! Use the framework in HTML pages or content scripts, it will just work 👍
|
||||||
|
|
||||||
|
```ts
|
||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
@@ -33,18 +64,7 @@ export default defineConfig({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
```ts [Svelte]
|
The WXT modules just simplify the configuration and add auto-imports. They're not much different than the above.
|
||||||
import { defineConfig } from 'wxt';
|
|
||||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
vite: () => ({
|
|
||||||
plugins: [svelte()],
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Multiple Apps
|
## Multiple Apps
|
||||||
|
|
||||||
@@ -84,9 +104,9 @@ Lots of frameworks come with routers for building a multi-page app using the URL
|
|||||||
|
|
||||||
Instead, you need to configure the router to run in "hash" mode, where the routing information is apart of the URL's hash, not the path (ie: `popup.html#/` and `popup.html#/account/settings`)
|
Instead, you need to configure the router to run in "hash" mode, where the routing information is apart of the URL's hash, not the path (ie: `popup.html#/` and `popup.html#/account/settings`)
|
||||||
|
|
||||||
Refer to your router's docs for information about "hash" mode and how to enable it. Here's a non-extensive list of a few popular routers:
|
Refer to your router's docs for information about hash mode and how to enable it. Here's a non-extensive list of a few popular routers:
|
||||||
|
|
||||||
- [React](https://reactrouter.com/en/main/routers/create-hash-router)
|
- [`react-router`](https://reactrouter.com/en/main/routers/create-hash-router)
|
||||||
- [Vue](https://router.vuejs.org/guide/essentials/history-mode.html#Hash-Mode)
|
- [`vue-router`](https://router.vuejs.org/guide/essentials/history-mode.html#Hash-Mode)
|
||||||
- [Svelte](https://www.npmjs.com/package/svelte-spa-router#hash-based-routing)
|
- [`svelte-spa-router`](https://www.npmjs.com/package/svelte-spa-router#hash-based-routing)
|
||||||
- [Solid](https://github.com/solidjs/solid-router?tab=readme-ov-file#hash-mode-router)
|
- [`solid-router`](https://github.com/solidjs/solid-router?tab=readme-ov-file#hash-mode-router)
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
Initial release 🎉
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.1
|
||||||
|
|
||||||
|
[compare changes](https://github.com/wxt-dev/wxt/compare/module-solid-v1.0.0...module-solid-v1.0.1)
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- Add `target: esnext` by default ([#733](https://github.com/wxt-dev/wxt/pull/733))
|
||||||
|
|
||||||
|
### 🏡 Chore
|
||||||
|
|
||||||
|
- Add changelog ([21e8ca0](https://github.com/wxt-dev/wxt/commit/21e8ca0))
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
Initial release 🎉
|
||||||
@@ -4,7 +4,7 @@ Enables the use of [SolidJS](https://www.solidjs.com/) in your web extension, in
|
|||||||
|
|
||||||
This plugin makes a few changes:
|
This plugin makes a few changes:
|
||||||
|
|
||||||
1. Adds `vite-plugin-solid` to vite
|
1. Adds `vite-plugin-solid` to and sets `build.target: esnext` in the vite config
|
||||||
2. Adds the [`solid-js` preset](https://github.com/unjs/unimport/blob/main/src/presets/solid.ts) to auto-imports
|
2. Adds the [`solid-js` preset](https://github.com/unjs/unimport/blob/main/src/presets/solid.ts) to auto-imports
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@wxt-dev/module-solid",
|
"name": "@wxt-dev/module-solid",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ export default defineWxtModule<SolidModuleOptions>({
|
|||||||
|
|
||||||
addViteConfig(wxt, () => ({
|
addViteConfig(wxt, () => ({
|
||||||
plugins: [solid(vite)],
|
plugins: [solid(vite)],
|
||||||
|
build: {
|
||||||
|
target: 'esnext',
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
addImportPreset(wxt, 'solid-js');
|
addImportPreset(wxt, 'solid-js');
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
Initial release 🎉
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
Initial release 🎉
|
||||||
@@ -29,5 +29,7 @@ await createGithubRelease(config, {
|
|||||||
tag_name: prevTag,
|
tag_name: prevTag,
|
||||||
name: `${pkgName} v${currentVersion}`,
|
name: `${pkgName} v${currentVersion}`,
|
||||||
body: releases[0].body,
|
body: releases[0].body,
|
||||||
|
// @ts-expect-error: Not typed in changelogen, but present: https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
|
||||||
|
make_latest: pkg === 'wxt',
|
||||||
});
|
});
|
||||||
consola.success('Created release');
|
consola.success('Created release');
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.3",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@vitejs/plugin-react": "^4.3.1",
|
"@wxt-dev/module-react": "^1.0.0",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"wxt": "^0.18.6"
|
"wxt": "^0.18.6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import react from '@vitejs/plugin-react';
|
|
||||||
|
|
||||||
// See https://wxt.dev/api/config.html
|
// See https://wxt.dev/api/config.html
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
vite: () => ({
|
modules: ['@wxt-dev/module-react'],
|
||||||
plugins: [react()],
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"vite-plugin-solid": "^2.10.2",
|
"@wxt-dev/module-solid": "^1.0.0",
|
||||||
"wxt": "^0.18.6"
|
"wxt": "^0.18.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import Solid from 'vite-plugin-solid';
|
|
||||||
|
|
||||||
// See https://wxt.dev/api/config.html
|
// See https://wxt.dev/api/config.html
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
vite: () => ({
|
modules: ['@wxt-dev/module-solid'],
|
||||||
build: {
|
|
||||||
target: 'esnext',
|
|
||||||
},
|
|
||||||
plugins: [Solid()],
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
"postinstall": "wxt prepare"
|
"postinstall": "wxt prepare"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.1",
|
|
||||||
"@tsconfig/svelte": "^5.0.4",
|
"@tsconfig/svelte": "^5.0.4",
|
||||||
|
"@wxt-dev/module-svelte": "^1.0.0",
|
||||||
"svelte": "^4.2.18",
|
"svelte": "^4.2.18",
|
||||||
"svelte-check": "^3.8.0",
|
"svelte-check": "^3.8.0",
|
||||||
"tslib": "^2.6.3",
|
"tslib": "^2.6.3",
|
||||||
|
|||||||
@@ -1,16 +1,7 @@
|
|||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import { svelte, vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
||||||
|
|
||||||
// See https://wxt.dev/api/config.html
|
// See https://wxt.dev/api/config.html
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
srcDir: 'src',
|
srcDir: 'src',
|
||||||
vite: () => ({
|
modules: ['@wxt-dev/module-svelte'],
|
||||||
plugins: [
|
|
||||||
svelte({
|
|
||||||
// Using a svelte.config.js file causes a segmentation fault when importing the file
|
|
||||||
configFile: false,
|
|
||||||
preprocess: [vitePreprocess()],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"vue": "^3.4.27"
|
"vue": "^3.4.27"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.0.5",
|
"@wxt-dev/module-vue": "^1.0.0",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"vue-tsc": "^2.0.21",
|
"vue-tsc": "^2.0.21",
|
||||||
"wxt": "^0.18.6"
|
"wxt": "^0.18.6"
|
||||||
|
|||||||
@@ -1,18 +1,6 @@
|
|||||||
import { defineConfig } from 'wxt';
|
import { defineConfig } from 'wxt';
|
||||||
import vue from '@vitejs/plugin-vue';
|
|
||||||
|
|
||||||
// See https://wxt.dev/api/config.html
|
// See https://wxt.dev/api/config.html
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
imports: {
|
modules: ['@wxt-dev/module-vue'],
|
||||||
addons: {
|
|
||||||
vueTemplate: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vite: () => ({
|
|
||||||
plugins: [vue()],
|
|
||||||
build: {
|
|
||||||
// Enabling sourcemaps with Vue during development is known to cause problems with Vue
|
|
||||||
sourcemap: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user