This esbuild plugin creates/writes files (asynchronously and in parallel) before and after bundling.
npm install esbuild-plugin-write-file
import esbuild from 'esbuild';
import writeFilePlugin from 'esbuild-plugin-write-file';
esbuild.build({
// ...
plugins: [writeFilePlugin({
before: { // write before bundling
'./src/template.html': 'template content',
'./src/license.txt': 'license content'
},
after: { // write after bundling
'./dist/report.json': JSON.stringify({hello: 'world'})
}
})]
});
before: {String targetPath: String content, ...}
An object with targetPath
: content
entries. Files are written before bundling.
after: {String targetPath: String content, ...}
An object with targetPath
: content
entries. Files are written after bundling.