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

This commit is contained in:
Simon Knott 2024-11-18 16:04:12 +01:00 коммит произвёл GitHub
Родитель 5e8b469c1c
Коммит 3fa33ca81f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -291,6 +291,25 @@ steps.push({
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.
// bug: https://github.com/vitejs/vite/issues/18655
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.
for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
steps.push({