add middleware to follow new stylesheet imports

This commit is contained in:
Cory LaViska
2025-01-02 13:04:39 -05:00
parent 71bf742af1
commit d84d78cab5

View File

@@ -38,6 +38,16 @@ export default {
bail: process.env['FAIL_FAST'] === 'true',
},
},
middleware: [
// When using relative CSS imports, we need to rewrite the paths so the test runner can find them.
function rewriteCssUrls(context, next) {
if (context.url.endsWith('.css') && context.url.match(/^\/[^/]+\//)) {
const theme = context.url.split('/')[1];
context.url = `/dist/styles/themes/${theme}${context.url.slice(theme.length + 1)}`;
}
return next();
},
],
plugins: [
esbuildPlugin({
ts: true,