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
},
};
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
},
};
Share
Improve this question
edited Feb 1, 2023 at 16:27
Ryan
asked Mar 27, 2021 at 15:25
RyanRyan
1,24213 silver badges24 bronze badges
1 Answer
Reset to default 5In 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',
},
};
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744968261a4603815.html
评论列表(0条)