forked from badeball/cypress-cucumber-preprocessor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.ts
29 lines (22 loc) · 705 Bytes
/
esbuild.ts
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
import esbuild from "esbuild";
import { ICypressConfiguration } from "@badeball/cypress-configuration";
import { compile } from "./lib/template";
export { ICypressConfiguration };
export function createEsbuildPlugin(
configuration: ICypressConfiguration
): esbuild.Plugin {
return {
name: "feature",
setup(build) {
const fs = require("fs") as typeof import("fs");
build.onLoad({ filter: /\.feature$/ }, async (args) => {
const content = await fs.promises.readFile(args.path, "utf8");
return {
contents: await compile(configuration, content, args.path),
loader: "js",
};
});
},
};
}
export default createEsbuildPlugin;