@@ -11,6 +11,7 @@ const version = pkg.version;
1111const dirname = path . resolve ( ) ;
1212const isDev = process . env . NODE_ENV === "development" ;
1313const isBeta = version . includes ( "-" ) ;
14+ const isReactTools = process . env . REACT_DEVTOOLS === "true" ;
1415
1516// Target browsers, see: https://github.com/browserslist/browserslist
1617// 依照 https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts#browser_compatibility
@@ -133,10 +134,14 @@ export default defineConfig({
133134 to : `${ dist } /ext` ,
134135 // 将manifest.json内版本号替换为package.json中版本号
135136 transform ( content : Buffer ) {
136- const manifest = JSON . parse ( content . toString ( ) ) ;
137+ const manifest = JSON . parse ( content . toString ( ) ) as chrome . runtime . ManifestV3 ;
137138 if ( isDev || isBeta ) {
138139 manifest . name = "__MSG_scriptcat_beta__" ;
139- // manifest.content_security_policy = "script-src 'self' https://cdn.crowdin.com; object-src 'self'";
140+ }
141+ if ( isReactTools ) {
142+ manifest . content_security_policy = {
143+ extension_pages : "script-src 'self' http://localhost:8097; object-src 'self'" ,
144+ } ;
140145 }
141146 return JSON . stringify ( manifest ) ;
142147 } ,
@@ -191,6 +196,9 @@ export default defineConfig({
191196 chunks : [ "import" ] ,
192197 } ) ,
193198 new rspack . HtmlRspackPlugin ( {
199+ templateParameters : {
200+ isReactTools : isReactTools ? "true" : "false" ,
201+ } ,
194202 filename : `${ dist } /ext/src/options.html` ,
195203 template : `${ src } /pages/options.html` ,
196204 inject : "head" ,
0 commit comments