Copies static files into output directory with support for hash replacement.
npm install rollup-plugin-static-filesRollup plugin that copies over static files from the specified directories into the output directory.
It also modifies HTML files to override hash values with the hash values generated by Rollup.
``npm install rollup-plugin-static-files`
`
let static_files = require('rollup-plugin-static-files');
module.exports = {
...
plugins: [
static_files({
include: ['./public'],
exclude: ['./public/userdata']
})
]
}
`
All HTML files are scanned for `script` and `link` tags. The `src` and `href` attributes are checked and if they match any emitted assets/chunks/entries, those attributes are replaced.
Your index file should refer to these files using their final names, generated by `assetFileNames`/`entryFileNames`/`chunkFileNames`, with the exception of `[hash]`. That should not be replaced.
Example:
`
`
If a HTML file includes files that start with a subdirectory, but this subdirectory is only mentioned in the `output.dir` option and not in `output.entryFileNames` etc, then use this option to make the plugin aware that all outputs start with this subdirectory.
Example:
`
output: {
dir: 'dist/client',
entryFileNames: '[name].[hash].js'
}
`
For the plugin:
```
static_files({
include: ['./public'],
publicPath: '/client'
})