Say that I have this basic rollup.config.js
file.
export default {
input: 'src/main.js',
output: {
format: 'iife',
file: 'dist/bundle.js',
}
};
I want the output file to have its hash in the file name (e.g. bundle-9f02a82b.js
). From what I can tell from the docs, the correct way to do this is with options.entryFileNames
. However, that setting doesn’t seem to have any effect when outputting to options.file
.
I have seen some people online mention that you can use [hash]
in output.file
, but that doesn’t seem to actually work.
export default {
input: 'src/main.js',
output: {
format: 'iife',
file: 'dist/bundle-[hash].js', // this doesn’t work
},
};
In order to get a hashed file name, you will have to replace output.file
with output.dir
and output.entryFileNames
.
In your example that would be:
export default {
input: 'src/main.js',
output: {
format: 'iife',
dir: 'build',
entryFileNames: 'bundle-[hash].js',
},
};