This commit is contained in:
5
test/rewrite-url/fixtures/admin/app.js
Normal file
5
test/rewrite-url/fixtures/admin/app.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export const bootstrap = (el,deps = [])=>{
|
||||
el.innerHtml = `
|
||||
<div>load the app</div>
|
||||
`;
|
||||
}
|
||||
8
test/rewrite-url/fixtures/admin/index.html
Normal file
8
test/rewrite-url/fixtures/admin/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="./app.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
8
test/rewrite-url/fixtures/index.html
Normal file
8
test/rewrite-url/fixtures/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="./admin/app.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
44
test/rewrite-url/test.js
Normal file
44
test/rewrite-url/test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import {resolve, join, dirname} from "node:path";
|
||||
import * as path from "node:path";
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/test.js";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
|
||||
const output = {
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
|
||||
};
|
||||
|
||||
import {fileURLToPath} from "node:url";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('rewrite-url', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: {
|
||||
['index']: 'index.html',
|
||||
['admin/index']: resolve(__dirname,'fixtures','admin/index.html'),
|
||||
['admin/app']: resolve(__dirname,'fixtures','admin/app.js'),
|
||||
},
|
||||
plugins: [
|
||||
html({
|
||||
rewriteUrl(relative, {rootPath, from}){
|
||||
return `/${rootPath}`;
|
||||
}
|
||||
}),
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
debugPrintOutput('rewrite-url',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
// TODO various parameters
|
||||
// - format: cjs, iifi, ...
|
||||
// - sourcemap: inline, false, (and the various exotic sourcemap options)
|
||||
// Watch mode tests would be its own dir
|
||||
// ...
|
||||
Reference in New Issue
Block a user