# refresh-when-js-updated **Repository Path**: ss0713/refresh-when-js-updated ## Basic Information - **Project Name**: refresh-when-js-updated - **Description**: Loading chunk *** failed - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-25 - **Last Updated**: 2022-01-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 1、简介(Introduction) webpack 的 plugin 插件,用于解决单页面应用 js 文件更新前,页面已加载,更新后,切换路由菜单,由于入口的 js 文件没更新,其他页面的 js 文件切分后的 hash 映射关系改变了,导致的 js 文件找不到报 404 的问题 - 解决:全局捕获监听 error 事件,当 error 为 js 加载 404,且在同域名下和有效时间内时,自动刷新更新 js 主文件。有效时间可配置 - 依赖 html-webpack-plugin 插件(depend on html-webpack-plugin) ### 2、安装(Install) ```bash npm i refresh-when-js-updated -S ``` ### 3、用法(Usage) ```js const RefreshWhenJSUpdatedPlugin = require("refresh-when-js-updated"); // option: {expireTime?:number} 默认30分钟 new RefreshWhenJSUpdatedPlugin({ expireTime: 60 * 30 }); ``` ### 4、参考资料