Hash 使用汇总对文件名进行哈希处理
我对bundler和Hash 使用汇总对文件名进行哈希处理,hash,rollupjs,Hash,Rollupjs,我对bundler和rollup非常陌生。在为生产构建时,在rollup.config.js中有条件地散列文件名,同时保存index.html以引用新的.css和.js散列版本的最佳方法是什么 我在中看到了这一点,但我想我不知道如何根据dev/prod设置有条件地设置这些选项 output: { sourcemap: true, format: 'iife', name: 'app', file: 'public/build/bun
rollup
非常陌生。在为生产构建时,在rollup.config.js
中有条件地散列文件名,同时保存index.html
以引用新的.css
和.js
散列版本的最佳方法是什么
我在中看到了这一点,但我想我不知道如何根据dev/prod
设置有条件地设置这些选项
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
// entryFileNames : 'bundle[hash].js
},
或者使用rollup plugin hash
是更好的解决方案?
仍然不确定更新index.html
(清单文件选项提供了什么?您可以使用类似的插件生成一个html文件,该文件引用散列文件名
由于汇总配置文件只是Javascript,因此可以根据dev/prod设置包含一些
const isProduction = process.env.NODE_ENV === 'production';
export default {
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: isProduction ? 'bundle[hash].js' : 'public/build/bundle.js',
}
};