Skip to content

v2.1.1

Choose a tag to compare

@BjornTheProgrammer BjornTheProgrammer released this 07 Nov 05:17
· 41 commits to main since this release

What's Changed

  • Added preprocessor option

An example of its usage can be found below

await Bun.build({
    entrypoints: ['src/index.html'],
    outdir: 'dist',
    minify: true,
    plugins: [html({
        async preprocessor(processor) {
            const files = processor.getFiles();

            for (const file of files) {
                if (file.extension == '.css') {
                    const contents = await $`bun run tailwindcss -i ${file.path} --content 'src/**/*.{html,js,ts}'`.quiet().text();
                    processor.writeFile(file.path, contents);
                }
            }

            // Add hello.txt to the out dir.
            // The path provided to writeFile must be an absolute path.
            processor.writeFile(path.resolve('src/hello.txt'), 'Hello World!')
        },
    })]
})

Full Changelog: v2.1.0...v2.1.1