Skip to content

Latest commit

 

History

History

webpack-loader-transform-dynamic-comp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

动态引入组件转换

替换动态组件。

比如下面的动态组件:

components: {
  xxComp(resolve) {
    require(['xx.comp'], resolve);
  },
}

会被转为:

import xxComp from 'xx.comp';

components: {
  xxComp,
}

如何使用

安装

pnpm add @plugin-light/webpack-loader-transform-dynamic-comp -D

vue.config.js 中添加如下设置:

const { LOADER: transformDynamicComp } = require('webpack-loader-transform-dynamic-comp')';

module.export = {
  chainWebpack(config) {
    config.module
      .rule('vue')
      .test(/\.vue$/)
      .use(transformDynamicComp)
      .loader(transformDynamicComp)
      .end();
  }
}

更新日志

点此查看