chore: HMR for Trace Viewer build script changes (#33291)

This commit is contained in:
Simon Knott 2024-11-08 15:08:58 +01:00 коммит произвёл GitHub
Родитель 93b7b6e279
Коммит f7a388dcb4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 34 добавлений и 19 удалений

2
packages/trace-viewer/.gitignore поставляемый
Просмотреть файл

@ -22,3 +22,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?
public/sw.bundle.js

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

@ -26,6 +26,9 @@ export default defineConfig({
react(),
bundle()
],
define: {
'process.env': {},
},
resolve: {
alias: {
'@injected': path.resolve(__dirname, '../playwright-core/src/server/injected'),
@ -38,8 +41,6 @@ export default defineConfig({
},
build: {
outDir: path.resolve(__dirname, '../playwright-core/lib/vite/traceViewer'),
// Output dir is shared with vite.sw.config.ts, clearing it here is racy.
emptyOutDir: false,
rollupOptions: {
input: {
index: path.resolve(__dirname, 'index.html'),

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

@ -35,9 +35,10 @@ export default defineConfig({
'@web': path.resolve(__dirname, '../web/src'),
},
},
publicDir: false,
build: {
outDir: path.resolve(__dirname, '../playwright-core/lib/vite/traceViewer'),
// Output dir is shared with vite.config.ts, clearing it here is racy.
// outputs into the public dir, where the build of vite.config.ts will pick it up
outDir: path.resolve(__dirname, 'public'),
emptyOutDir: false,
rollupOptions: {
input: {

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

@ -275,6 +275,22 @@ for (const bundle of bundles) {
});
}
// Build/watch trace viewer service worker.
steps.push({
command: 'npx',
args: [
'vite',
'--config',
'vite.sw.config.ts',
'build',
...(watchMode ? ['--watch', '--minify=false'] : []),
...(withSourceMaps ? ['--sourcemap=inline'] : []),
],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'),
concurrent: watchMode, // feeds into trace-viewer's `public` directory, so it needs to be finished before trace-viewer build starts
});
// Build/watch web packages.
for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
steps.push({
@ -290,22 +306,17 @@ for (const webPackage of ['html-reporter', 'recorder', 'trace-viewer']) {
concurrent: true,
});
}
// Build/watch trace viewer service worker.
steps.push({
command: 'npx',
args: [
'vite',
'--config',
'vite.sw.config.ts',
'build',
...(watchMode ? ['--watch', '--minify=false'] : []),
...(withSourceMaps ? ['--sourcemap=inline'] : []),
],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'),
concurrent: true,
});
// web packages dev server
if (watchMode) {
steps.push({
command: 'npx',
args: ['vite', '--port', '44223', '--base', '/trace/'],
shell: true,
cwd: path.join(__dirname, '..', '..', 'packages', 'trace-viewer'),
concurrent: true,
});
}
// Generate injected.
onChanges.push({