This is a plug-in that converts wechat applet custom components into other applet custom components.
这是一个可将微信小程序自定义组件转换为其他小程序自定义组件的插件。
npm install rollup-plugin-minip-components-transfer --save-dev
rollup.config.js
import { jsTransfer, wxmlTransfer } from 'rollup-plugin-minip-components-transfer';
import copy from 'rollup-plugin-copy';
const platform = 'my' // 可取值 'my'、'swan'、'tt'、'qq'
const suffix = {
wx: '.wxss',
my: '.acss',
swan: '.css',
tt: '.ttss',
qq: '.qss'
};
const config = {
plugins: [
jsTransfer({
platform: platform,
include: 'src/components/myComponent/myComponent.js'
}),
wxmlTransfer({
platform: platform,
template: 'src/components/myComponent/myComponent.wxml',
name: 'myComponent',
output: `dist/components/${platform}`
}),
// 配合copy plugin直接复制json和样式表文件,并同时重命名和简单压缩样式表文件
copy({
targets: [
{
src: 'src/components/myComponent/myComponent.json',
dest: `dist/components/${platform}/myComponent`,
rename: 'myComponent.json'
},
{
src: 'src/components/myComponent/myComponent.wxss',
dest: `dist/components/${platform}/myComponent`,
transform: (contents) => contents.toString().replace(/\s+/g, ''),
rename: `myComponent${suffix[platform]}`
}
]
}),
};
The content of small program syntax conversion is limited, and only some simple methods can be converted, which can not be converted perfectly. I will continue to supplement and improve.
小程序语法转换内容有限,仅可转部分简单的方法,还不能完美转换。我会继续补充完善。