为什么要缩窄route范围
对于一些大单页,单个router-view中可能包含上百个页面。但是开发的时候其实并不需要那么多调试那么多页面。
因此,为了节省不必要的打包和热更新时间,可以对route进行缩窄
缩窄route的方式
笔者这里以webpack-plugin的方式去做构建时的route文件变更,plugin逻辑大致如下:
// 在 environment 阶段去做文件覆写
class LimitRoutePlugin {
apply(compiler) {
const absoluteFilePath =
'/Users/xxxxxx/route.ts';
compiler.hooks