@@ -91,8 +91,13 @@ module.exports = (env) => {
9191 test : / e n v i r o n m e n t \. t s $ / ,
9292 loader : 'file-replace-loader' ,
9393 options : {
94- condition : mode === 'development' ,
95- replacement : resolve ( './src/environment.dev.ts' ) ,
94+ // Activate replacement if mode is development OR staging
95+ condition : mode === 'development' || mode === 'staging' ,
96+ // Dynamically route to the correct file
97+ replacement :
98+ mode === 'staging'
99+ ? resolve ( './src/environment.staging.ts' )
100+ : resolve ( './src/environment.dev.ts' ) ,
96101 } ,
97102 } ,
98103 {
@@ -110,7 +115,7 @@ module.exports = (env) => {
110115 new CopyPlugin ( {
111116 patterns : [
112117 { from : 'icons' , to : 'icons' , context : '.' } ,
113- { from : 'data' , to : 'data' , context : '.' , globOptions : { ignore : [ 'bluegem.json' ] } } ,
118+ { from : 'data' , to : 'data' , context : '.' , globOptions : { ignore : [ 'bluegem.json' ] } } ,
114119 { from : 'src/global.css' , to : 'src/' , context : '.' } ,
115120 { from : 'src/background_ff.html' , to : 'src/' , context : '.' } ,
116121 { from : 'src/steamcommunity_ruleset.json' , to : 'src/' , context : '.' } ,
@@ -149,6 +154,31 @@ module.exports = (env) => {
149154 processed . externally_connectable . matches . push ( 'http://localhost:4200/*' ) ;
150155 }
151156
157+ if ( mode === 'staging' ) {
158+ // https://developer.chrome.com/docs/extensions/develop/migrate/publish-mv3#publish-beta
159+ // Grab the run number from the GitHub Action environment, default to 0 for local builds
160+ const runNumber = process . env . GITHUB_RUN_NUMBER || '0' ;
161+
162+ // Append the run number to the strict version (e.g., 5.14.0.42)
163+ processed . version = `${ processed . version } .${ runNumber } ` ;
164+
165+ // Update names
166+ processed . name += ' - STAGING' ;
167+ processed . short_name += ' (Staging)' ;
168+ processed . version_name = `${ processed . version } (Staging)` ;
169+
170+ if ( ! processed . externally_connectable . matches . includes ( '*://*.csfloat.build/*' ) ) {
171+ processed . externally_connectable . matches . push ( '*://*.csfloat.build/*' ) ;
172+ }
173+
174+ const versionResource = processed . web_accessible_resources . find ( ( e ) =>
175+ e . resources [ 0 ] . includes ( 'version.txt' )
176+ ) ;
177+ if ( versionResource && ! versionResource . matches . includes ( 'https://csfloat.build/*' ) ) {
178+ versionResource . matches . push ( 'https://csfloat.build/*' ) ;
179+ }
180+ }
181+
152182 if ( env . browser === 'firefox' ) {
153183 processed = convertToFirefoxManifest ( processed ) ;
154184 }
@@ -162,17 +192,23 @@ module.exports = (env) => {
162192 transform ( raw ) {
163193 let processed = JSON . parse ( raw . toString ( ) ) ;
164194
195+ // Apply the exact same version bump for staging
196+ if ( mode === 'staging' ) {
197+ const runNumber = process . env . GITHUB_RUN_NUMBER || '0' ;
198+ return `${ processed . version } .${ runNumber } ` ;
199+ }
200+
165201 return processed . version ;
166202 } ,
167203 } ,
168204 ] ,
169205 } ) ,
170206 // Add Gzip compression for bluegem.json
171207 new CompressionPlugin ( {
172- filename : " [path][base].gz" , // Change extension to .gz
173- algorithm : " gzip" ,
208+ filename : ' [path][base].gz' , // Change extension to .gz
209+ algorithm : ' gzip' ,
174210 test : / b l u e g e m \. j s o n $ / ,
175- deleteOriginalAssets : true ,
211+ deleteOriginalAssets : true ,
176212 } ) ,
177213 new webpack . ProvidePlugin ( {
178214 Buffer : [ 'buffer' , 'Buffer' ] ,
@@ -192,7 +228,7 @@ module.exports = (env) => {
192228 headers : {
193229 'Cross-Origin-Embedder-Policy' : 'require-corp' ,
194230 'Cross-Origin-Opener-Policy' : 'same-origin' ,
195- }
231+ } ,
196232 } ,
197233 } ;
198234} ;
0 commit comments