import {join, dirname} from "node:path"; import test from "ava"; import { rollup } from "rollup"; import urlPlugin from "@rollup/plugin-url"; import html from "../../src/index.ts"; import serveTest from "../util/test-server.ts"; /** * @type {OutputOptions} */ 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 chunkFileNames: '[name].js', entryFileNames: '[name].[extname]', assetFileNames: '[name].[extname]', }; import {fileURLToPath} from "node:url"; import handlebars from "handlebars"; const __dirname = dirname(fileURLToPath(import.meta.url)); process.chdir(join(__dirname, 'fixtures')); const defaultAssetInclude = [ '**/*.(png|jpg|jpeg|gif|ico|svg)',// images, svg '**/*.(woff|woff2|eot|ttf|otf)',// fonts '**/*.(webm|mp4)',// video ]; test.serial('web-bundle', async (t) => { const bundle = await rollup({ input: 'index.hbs', treeshake: 'smallest', plugins: [ html({ transform(src) { return handlebars.compile(src)({ head: `I'm cool!` }); } }), urlPlugin({ include: defaultAssetInclude, }), serveTest({ path: 'index.html', t, }) ], }); await bundle.generate(output); });