延迟加载角度2组件缓存问题 [英] lazy load angular 2 components cache issue

查看:56
本文介绍了延迟加载角度2组件缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

角度2将延迟加载的组件命名为0.js 1.js等.入口点具有版本前缀,但是所有延迟加载的组件均与以前相同,这会导致浏览器中的代码版本不一致(main.js是新的,而0.js浏览器使用的是旧文件)

angular 2 naming lazy loaded components as 0.js 1.js ect. entry point have version prepended but all lazy loaded components remains same as before which results in inconsistent version of code in browser (main.js is new and 0.js browser uses old file)

推荐答案

Webpack开箱即用地提供了块文件名哈希. https://webpack.js.org/configuration/output/#output-chunkfilename

Webpack offers chunk filename hash out of the box. https://webpack.js.org/configuration/output/#output-chunkfilename

简单地添加到我的配置文件中

simply added to my config file

chunkFilename: '[name].[chunkhash].chunk.js'

问题已经解决!

这篇关于延迟加载角度2组件缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆