11import { execSync } from 'node:child_process' ;
2+ import { readFile , writeFile } from 'node:fs/promises' ;
3+ import path from 'node:path' ;
24import { GenerateSW } from '@aaroon/workbox-rspack-plugin' ;
3- import { defineConfig } from '@rsbuild/core' ;
5+ import { defineConfig , type RsbuildPlugin } from '@rsbuild/core' ;
46import { pluginBabel } from '@rsbuild/plugin-babel' ;
57import { pluginSass } from '@rsbuild/plugin-sass' ;
68import { pluginSolid } from '@rsbuild/plugin-solid' ;
@@ -31,7 +33,8 @@ export default defineConfig({
3133 pluginSass ( ) ,
3234 ] ,
3335 html : {
34- template : './src/index.browser.html' ,
36+ template : './src/index.html' ,
37+ title : '' ,
3538 } ,
3639 output : {
3740 polyfill : 'usage' ,
@@ -50,7 +53,7 @@ export default defineConfig({
5053 port : process . env . NODE_ENV === 'development' ? 3000 : 8080 ,
5154 publicDir : false ,
5255 } ,
53- tools : { } ,
56+
5457 source : {
5558 define : {
5659 IS_TAURI : false ,
@@ -85,6 +88,22 @@ export default defineConfig({
8588 ] ,
8689 } ,
8790 } ,
91+ plugins : [
92+ {
93+ name : 'web-manifest-plugin' ,
94+ setup ( api ) {
95+ api . onBeforeBuild ( async ( ) => {
96+ const { rootPath, distPath } = api . context ;
97+ const manifest = await readFile ( path . join ( rootPath , './src/manifest.json' ) , { encoding : 'utf-8' } ) ;
98+ const replacedManifest = manifest . replaceAll (
99+ '<%= process.env.BASE_URL %>' ,
100+ api . getRsbuildConfig ( 'current' ) . output . assetPrefix ,
101+ ) ;
102+ await writeFile ( path . join ( distPath , 'manifest.json' ) , replacedManifest ) ;
103+ } ) ;
104+ } ,
105+ } satisfies RsbuildPlugin ,
106+ ] ,
88107 } ,
89108 tauri : {
90109 output : {
@@ -99,10 +118,6 @@ export default defineConfig({
99118 CONFIG_ENABLE_PWA : false ,
100119 } ,
101120 } ,
102- html : {
103- template : './src/index.tauri.html' ,
104- title : '' ,
105- } ,
106121 } ,
107122 } ,
108123} ) ;
0 commit comments