File tree Expand file tree Collapse file tree 15 files changed +3480
-2618
lines changed
Expand file tree Collapse file tree 15 files changed +3480
-2618
lines changed Original file line number Diff line number Diff line change 1+ import fs from "fs" ;
2+ const packageJson = JSON . parse ( fs . readFileSync ( "./package.json" , "utf8" ) ) ;
3+
4+ const manifest : chrome . runtime . ManifestV3 = {
5+ manifest_version : 3 ,
6+ name : packageJson . name ,
7+ version : packageJson . version ,
8+ description : packageJson . description || "" ,
9+ action : {
10+ default_popup : "./src/popup/index.html" ,
11+ } ,
12+ background : {
13+ service_worker : "./src/background/index.ts" ,
14+ type : "module" ,
15+ } ,
16+ devtools_page : "./src/devtools/index.html" ,
17+ } ;
18+
19+ export default manifest ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " rsbuild-chrome-extension-boilerplate-react" ,
3+ "description" : " A boilerplate for building Chrome extensions with rsbuild and React" ,
4+ "private" : true ,
5+ "version" : " 1.0.0" ,
6+ "scripts" : {
7+ "dev" : " rsbuild dev --open" ,
8+ "build:watch" : " rsbuild build --watch" ,
9+ "build" : " rsbuild build" ,
10+ "preview" : " rsbuild preview"
11+ },
12+ "type" : " module" ,
13+ "dependencies" : {
14+ "react" : " ^19.0.0" ,
15+ "react-dom" : " ^19.0.0"
16+ },
17+ "devDependencies" : {
18+ "rsbuild-plugin-web-extension" : " 0.0.10" ,
19+ "@rsbuild/core" : " ^1.0.16" ,
20+ "@rsbuild/plugin-react" : " ^1.0.5" ,
21+ "@types/chrome" : " ^0.0.263" ,
22+ "@types/node" : " ^20.11.28" ,
23+ "@types/react" : " ^18.2.47" ,
24+ "@types/react-dom" : " ^18.2.18" ,
25+ "typescript" : " ^5.4.2"
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ import { defineConfig } from "@rsbuild/core" ;
2+ import { pluginReact } from "@rsbuild/plugin-react" ;
3+ import { pluginWebExtension } from "rsbuild-plugin-web-extension" ;
4+ import manifest from "./manifest" ;
5+
6+ export default defineConfig ( {
7+ plugins : [
8+ pluginReact ( ) ,
9+ pluginWebExtension ( {
10+ manifest,
11+ } ) ,
12+ ] ,
13+ } ) ;
Original file line number Diff line number Diff line change 1+ console . log ( "background script" ) ;
Original file line number Diff line number Diff line change 1+ import { useState } from "react" ;
2+
3+ export const DevTools = ( ) => {
4+ const [ count , setCount ] = useState ( 0 ) ;
5+
6+ return (
7+ < div >
8+ < p > Count: { count } </ p >
9+ < button onClick = { ( ) => setCount ( count + 1 ) } > Increment</ button >
10+ </ div >
11+ ) ;
12+ } ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < title > DevTools</ title >
6+ </ head >
7+
8+ < body >
9+ < div id ="root "> </ div >
10+ </ body >
11+ < script type ="module " src ="./index.tsx "> </ script >
12+ </ html >
Original file line number Diff line number Diff line change 1+ import { createRoot } from "react-dom/client" ;
2+ import { DevTools } from "./devtools" ;
3+
4+ const root = createRoot ( document . querySelector ( "#root" ) ! ) ;
5+
6+ root . render ( < DevTools /> ) ;
Original file line number Diff line number Diff line change 1+ /// <reference types="@rsbuild/core/types" />
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < title > Popup</ title >
6+ </ head >
7+
8+ < body >
9+ < div id ="root "> </ div >
10+ </ body >
11+ < script type ="module " src ="./index.tsx "> </ script >
12+ </ html >
Original file line number Diff line number Diff line change 1+ import { createRoot } from "react-dom/client" ;
2+ import { Popup } from "./popup" ;
3+
4+ const root = createRoot ( document . querySelector ( "#root" ) ! ) ;
5+
6+ root . render ( < Popup /> ) ;
You can’t perform that action at this time.
0 commit comments