chore: address deprecated Vite warnings
This commit is contained in:
parent
f374f8db38
commit
d3a5569290
|
|
@ -14,8 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs, { existsSync } from 'fs';
|
||||
import path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import type { Plugin, UserConfig } from 'vite';
|
||||
|
||||
export function bundle(): Plugin {
|
||||
|
|
@ -26,7 +26,7 @@ export function bundle(): Plugin {
|
|||
config = c;
|
||||
},
|
||||
transformIndexHtml: {
|
||||
transform(html, ctx) {
|
||||
handler(html, ctx) {
|
||||
if (!ctx || !ctx.bundle)
|
||||
return html;
|
||||
html = html.replace(/(?=<!--)([\s\S]*?)-->/, '');
|
||||
|
|
@ -42,7 +42,7 @@ export function bundle(): Plugin {
|
|||
},
|
||||
},
|
||||
closeBundle: () => {
|
||||
if (existsSync(path.join(config.build!.outDir!, 'index.html'))) {
|
||||
if (fs.existsSync(path.join(config.build!.outDir!, 'index.html'))) {
|
||||
const targetDir = path.join(__dirname, '..', 'playwright-core', 'lib', 'vite', 'htmlReport');
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
fs.copyFileSync(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"name": "html-reporter",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build && tsc",
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
"module": "esnext",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
"include": ["vite.config.ts", "bundle.ts"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"name": "recorder",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build && tsc",
|
||||
|
|
|
|||
|
|
@ -14,23 +14,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @returns {import('vite').Plugin}
|
||||
*/
|
||||
export function bundle() {
|
||||
let config;
|
||||
import type { Plugin } from 'vite';
|
||||
|
||||
export function bundle(): Plugin {
|
||||
return {
|
||||
name: 'playwright-bundle',
|
||||
config(c) {
|
||||
config = c;
|
||||
},
|
||||
transformIndexHtml: {
|
||||
transform(html, ctx) {
|
||||
handler(html, ctx) {
|
||||
if (!ctx || !ctx.bundle)
|
||||
return html;
|
||||
// Workaround vite issue that we cannot exclude some scripts from preprocessing.
|
||||
return html.replace(/(?=<!--)([\s\S]*?)-->/, '').replace('<!-- <script src="stall.js"></script> -->', '<script src="stall.js"></script>');
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
"name": "trace-viewer",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build && tsc",
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
"module": "esnext",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
"include": ["vite.config.ts", "bundle.ts"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
// @ts-ignore
|
||||
import { bundle } from './bundle';
|
||||
import * as path from 'path';
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
// @ts-ignore
|
||||
import { bundle } from './bundle';
|
||||
import * as path from 'path';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue