-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3366c08
commit b8bfaa9
Showing
5 changed files
with
576 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!doctype html> | ||
<html> | ||
<head></head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
import { type OutputAsset, rollup } from "rollup"; | ||
import { type OutputAsset, rollup, type RollupOutput } from "rollup"; | ||
import { build } from "vite"; | ||
|
||
import htaccess, { type Options } from "../src"; | ||
|
||
function extractFileContents(output: RollupOutput): string { | ||
const htaccessFiles = output.output.filter( | ||
(file): file is OutputAsset => | ||
file.type === "asset" && file.fileName === ".htaccess", | ||
); | ||
expect(htaccessFiles).toHaveLength(1); | ||
return htaccessFiles[0].source.toString(); | ||
} | ||
|
||
export async function compileRollup( | ||
options?: Partial<Options>, | ||
): Promise<string> { | ||
const bundle = await rollup({ | ||
input: "__tests__/fixtures/dummy.js", | ||
plugins: [htaccess(options)], | ||
}); | ||
const { output } = await bundle.generate({}); | ||
const htaccessFiles = output.filter( | ||
(file): file is OutputAsset => | ||
file.type === "asset" && file.fileName === ".htaccess", | ||
); | ||
expect(htaccessFiles).toHaveLength(1); | ||
return htaccessFiles[0].source.toString(); | ||
const output = await bundle.generate({}); | ||
return extractFileContents(output); | ||
} | ||
|
||
export async function compileVite(options?: Partial<Options>): Promise<string> { | ||
const output = (await build({ | ||
build: { | ||
rollupOptions: { | ||
input: { | ||
app: "__tests__/fixtures/dummy.html", | ||
}, | ||
}, | ||
}, | ||
plugins: [htaccess(options)], | ||
})) as Array<RollupOutput> | RollupOutput; | ||
return extractFileContents(Array.isArray(output) ? output[0] : output); | ||
} |
Oops, something went wrong.