This esbuild plugin copies files (asynchronously and in parallel) before and after bundling.
npm install esbuild-plugin-copy-file
import esbuild from 'esbuild';
import copyFilePlugin from 'esbuild-plugin-copy-file';
esbuild.build({
// ...
plugins: [copyFilePlugin({
before: { // copy before bundling
'./assets/favicon.png': './media/images/favicon.png'
},
after: { // copy after bundling
'./logs/build-report.json': './dist/report.json'
}
})]
});
before: {String targetPath: String sourcePath, ...}
An object with targetPath
: sourcePath
entries. Files are copied before bundling.
after: {String targetPath: String sourcePath, ...}
An object with targetPath
: sourcePath
entries. Files are copied after bundling.