23
23
# Run this script every time you update an *.mjs file or any of the
24
24
# modules it loads.
25
25
26
- OLD_WEBPACK_CONFIG_JS = ""
26
+ OLD_RSPACK_CONFIG_JS = ""
27
27
28
- WEBPACK_CONFIG_JS_PATH = os .path .join (TRANSPILE_CACHE_PATH , "webpack .config.js" )
28
+ RSPACK_CONFIG_JS_PATH = os .path .join (TRANSPILE_CACHE_PATH , "rspack .config.js" )
29
29
30
30
try :
31
- with open (WEBPACK_CONFIG_JS_PATH ) as file :
32
- OLD_WEBPACK_CONFIG_JS = file .read ()
31
+ with open (RSPACK_CONFIG_JS_PATH ) as file :
32
+ OLD_RSPACK_CONFIG_JS = file .read ()
33
33
except OSError :
34
34
pass
35
35
@@ -199,14 +199,14 @@ def handle(self, *args, **options):
199
199
static_base_url = PrefixNode .handle_simple ("STATIC_URL" )
200
200
transpile_base_url = urljoin (static_base_url , "js/" )
201
201
if (
202
- hasattr (settings , "WEBPACK_CONFIG_TEMPLATE " )
203
- and settings .WEBPACK_CONFIG_TEMPLATE
202
+ hasattr (settings , "RSPACK_CONFIG_TEMPLATE " )
203
+ and settings .RSPACK_CONFIG_TEMPLATE
204
204
):
205
- webpack_config_template_path = settings .WEBPACK_CONFIG_TEMPLATE
205
+ rspack_config_template_path = settings .RSPACK_CONFIG_TEMPLATE
206
206
else :
207
- webpack_config_template_path = os .path .join (
207
+ rspack_config_template_path = os .path .join (
208
208
os .path .dirname (os .path .realpath (__file__ )),
209
- "webpack .config.template.js" ,
209
+ "rspack .config.template.js" ,
210
210
)
211
211
entries = {}
212
212
for mainfile in mainfiles :
@@ -242,8 +242,8 @@ def handle(self, *args, **options):
242
242
urljoin (static_base_url , x ) for x in static_frontend_files
243
243
],
244
244
}
245
- with open (webpack_config_template_path ) as f :
246
- webpack_config_template = f .read ()
245
+ with open (rspack_config_template_path ) as f :
246
+ rspack_config_template = f .read ()
247
247
settings_dict = {}
248
248
for var in dir (settings ):
249
249
if var in ["DATABASES" , "SECRET_KEY" ]:
@@ -253,15 +253,15 @@ def handle(self, *args, **options):
253
253
settings_dict [var ] = getattr (settings , var )
254
254
except AttributeError :
255
255
pass
256
- webpack_config_js = webpack_config_template .replace (
256
+ rspack_config_js = rspack_config_template .replace (
257
257
"window.transpile" ,
258
258
json .dumps (transpile ),
259
259
).replace ("window.settings" , json .dumps (settings_dict , default = lambda x : False ))
260
260
261
- if webpack_config_js is not OLD_WEBPACK_CONFIG_JS :
262
- with open (WEBPACK_CONFIG_JS_PATH , "w" ) as f :
263
- f .write (webpack_config_js )
264
- call (["./node_modules/.bin/webpack " ], cwd = TRANSPILE_CACHE_PATH )
261
+ if rspack_config_js is not OLD_RSPACK_CONFIG_JS :
262
+ with open (RSPACK_CONFIG_JS_PATH , "w" ) as f :
263
+ f .write (rspack_config_js )
264
+ call (["./node_modules/.bin/rspack " ], cwd = TRANSPILE_CACHE_PATH )
265
265
end = int (round (time .time ()))
266
266
self .stdout .write ("Time spent transpiling: " + str (end - start ) + " seconds" )
267
267
signals .post_transpile .send (sender = None )
0 commit comments