1.0.0 • Published 5 months ago
@plugin-light/webpack-loader-replace-template-tag v1.0.0
Vue 模板标签转换
替换 Vue 模板中的标签,比如把REPLACE_TAG_SCROLL_VIEW在web端替换成div,在小程序端替换为scroll-view。
如何使用
安装
pnpm add @plugin-light/webpack-loader-replace-template-tag -D在 vue.config.js 中添加如下设置:
const { LOADER: replaceTemplateTag } = require('@plugin-light/webpack-loader-replace-template-tag');
module.export = {
chainWebpack(config) {
config.module
.rule('vue')
.test(/\.vue$/)
.use(replaceTemplateTag)
.loader(replaceTemplateTag)
.options({
replaceTmpTagMap: {
REPLACE_TAG_SCROLL_VIEW: {
web: 'div',
mp: 'scroll-view',
},
}
})
.end();
}
}参数
export type IReplaceTemplateTagOptions = {
// 替换标签映射表
replaceTmpTagMap?: {
[k: string]: {
mp: string;
web: string;
}
}
};