-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbundle.js
More file actions
28 lines (24 loc) · 819 Bytes
/
bundle.js
File metadata and controls
28 lines (24 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { readFileSync } from 'fs';
import { join } from 'path';
import * as url from 'url';
import process from 'process';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const htmlReportPath = join(__dirname, 'sample', 'htmlReport.json');
const vrtReportPath = join(__dirname, 'sample', 'vrtReport.json');
const isVRT = process.env.VITE_PRODUCT === 'vrt';
const sampleReportPath = isVRT ? vrtReportPath : htmlReportPath;
/**
* @returns {import('vite').Plugin}
*/
export function bundle() {
return {
name: 'nightwatch-bundle',
apply: 'serve',
transformIndexHtml: {
transform(html, _ctx) {
const reportData = readFileSync(sampleReportPath, { encoding: 'utf8' });
return html + `<script>window.nightwatchReport = ${reportData}</script>`;
}
}
};
}