chore(build): fix bug where sw changes aren't copied in watch mode

This commit is contained in:
Simon Knott 2024-11-13 13:19:57 +01:00
parent cd41404b05
commit 04a62cd2ec
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -291,6 +291,24 @@ steps.push({
concurrent: watchMode, // feeds into trace-viewer's `public` directory, so it needs to be finished before trace-viewer build starts concurrent: watchMode, // feeds into trace-viewer's `public` directory, so it needs to be finished before trace-viewer build starts
}); });
if (watchMode) {
// the build above outputs into `packages/trace-viewer/public`, where the `vite build` for `packages/trace-viewer` is supposed to pick it up.
// there's a bug in `vite build --watch` though where the public dir is only copied over initially, but its not watched.
// to work around this, we run a second watch build of the service worker into the final output.
steps.push({
command: 'npx',
args: [
'vite', '--config', 'vite.sw.config.ts',
'build', '--watch', '--minify=false',
'--outDir', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'vite', 'trace-viewer'),
'--emptyOutDir=false'
],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'),
concurrent: true
});
}
// Build/watch web packages. // Build/watch web packages.
for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) { for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
steps.push({ steps.push({