uniapp-vue3-vite-ts-template/unocss.config.js
2022-11-21 11:24:25 +08:00

57 lines
1.3 KiB
JavaScript

/*
* https://zhuanlan.zhihu.com/p/569976147
* */
import presetWeapp from 'unocss-preset-weapp';
import { defineConfig } from 'unocss';
import {
defaultAttributes,
defaultIgnoreNonValuedAttributes,
transformerAttributify,
transformerClass,
} from 'unocss-preset-weapp/transformer';
const transformRules = {
'.': '-d111-',
'/': '-s111-',
':': '-c111-',
'%': '-p111-',
'!': '-e111-',
'#': '-w111-',
'(': '-b111l-',
')': '-b111r-',
'[': '-f111l-',
']': '-f111r-',
$: '-r111-',
',': '-r222-',
};
export default defineConfig({
presets: [
// https://github.com/MellowCo/unocss-preset-weapp
presetWeapp({
nonValuedAttribute: true,
prefix: 'uno-',
}),
],
shortcuts: [
{
'border-base': 'border border-gray-500_10',
center: 'flex justify-center items-center',
},
],
// v0.1.14 unplugin-attributify-to-class 和 unplugin-transform-class 内置到 transformer 中
transformers: [
// options 见 https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
transformerAttributify({
transformRules,
}),
// options 见 https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
transformerClass({
transformRules,
}),
],
});