82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
/**
|
|
* unocss defineConfig
|
|
* @link unocss: https://github.com/unocss/unocss
|
|
* @link unocss-preset-weapp: https://github.com/MellowCo/unocss-preset-weapp
|
|
*/
|
|
|
|
import { defineConfig, presetIcons } from 'unocss';
|
|
import presetWeapp from 'unocss-preset-weapp';
|
|
import { transformerAttributify, transformerClass } from 'unocss-preset-weapp/transformer';
|
|
import transformerDirectives from '@unocss/transformer-directives';
|
|
import { themeVars } from './src/theme/vars';
|
|
|
|
const transformRules = {
|
|
'.': '-d111-',
|
|
'/': '-s111-',
|
|
':': '-c111-',
|
|
'%': '-p111-',
|
|
'!': '-e111-',
|
|
'#': '-w111-',
|
|
'(': '-b111l-',
|
|
')': '-b111r-',
|
|
'[': '-f111l-',
|
|
']': '-f111r-',
|
|
'$': '-r111-',
|
|
',': '-r222-',
|
|
};
|
|
|
|
const prefix = '';
|
|
|
|
export default defineConfig({
|
|
presets: [
|
|
// https://github.com/MellowCo/unocss-preset-weapp
|
|
presetWeapp({
|
|
nonValuedAttribute: true,
|
|
prefix,
|
|
whRpx: true,
|
|
transform: true,
|
|
platform: 'uniapp',
|
|
transformRules,
|
|
}),
|
|
// 由 Iconify 提供支持的纯 CSS 图标解决方案
|
|
presetIcons({
|
|
scale: 1,
|
|
warn: true,
|
|
extraProperties: {
|
|
'display': 'inline-block',
|
|
'vertical-align': 'middle',
|
|
},
|
|
}),
|
|
],
|
|
// transformers: [transformerDirectives()],
|
|
// attributify: false,
|
|
shortcuts: [
|
|
{
|
|
'border-base': 'border border-gray-500_10',
|
|
'z-tar-both': 'z-988',
|
|
'head-fixed': 'fixed top-0 left-0 w-full z-tar-both',
|
|
'center': 'flex justify-center items-center',
|
|
},
|
|
],
|
|
theme: {
|
|
extend: { opacity: { disabled: 'var(--opacity-disabled)' } },
|
|
...themeVars(),
|
|
},
|
|
|
|
transformers:
|
|
[
|
|
transformerDirectives({
|
|
applyVariable: ['--at-apply', '--uno-apply', '--uno'],
|
|
enforce: 'pre',
|
|
}),
|
|
transformerAttributify({
|
|
classPrefix: prefix,
|
|
transformRules,
|
|
nonValuedAttribute: true,
|
|
}),
|
|
transformerClass({
|
|
transformRules,
|
|
}),
|
|
],
|
|
});
|