-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcypress.config.js
64 lines (54 loc) · 1.71 KB
/
cypress.config.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { defineConfig } = require("cypress");
const { MemoryFS } = require("@parcel/fs");
const { Parcel, createWorkerFarm } = require("@parcel/core");
/**
*
* @param {Cypress.DevServerConfig} cypressConfig
*/
async function createParcelDevServer(cypressConfig) {
// let workerFarm = createWorkerFarm();
// let outputFS = new MemoryFS();
const PORT = 1234;
console.log("Create");
let bundler = new Parcel({
entries: cypressConfig.specs.map((x) => x.relative),
defaultConfig: "@parcel/config-default",
// outputFS,
serveOptions: {
port: PORT,
publicUrl: "__cypress/src",
},
hmrOptions: {
port: PORT,
},
});
console.log(bundler);
let { bundleGraph, buildTime } = await bundler.run();
let bundles = bundleGraph.getBundles();
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
// console.log({bundleGraph, bundles})
bundles.forEach(async (b) => {
// await outputFS.writeFile(b.filePath.replace('src', 'dist'), b.getMainEntry().getCode())
// console.log('wrote', b.filePath.replace('src', 'dist'), b.getMainEntry()?.getCode())
// console.log(b.id, b.name, b.displayName, b.filePath, b.getMainEntry()?.getCode());
console.log("bundle", JSON.stringify(b, null, 2));
});
await bundler.watch();
// await workerFarm.end()
return {
port: PORT,
close: () => {},
};
}
module.exports = defineConfig({
component: {
excludeSpecPattern: "dist/**/*",
async devServer(cypressConfig) {
// return devServer instance or a promise that resolves to
// a dev server here
const parcel = await createParcelDevServer(cypressConfig);
return parcel;
},
indexHtmlFile: "./component-index.html",
},
});