Skip to content

Commit

Permalink
fix: 🐛 修复插件导致的编译错误
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Feb 5, 2024
1 parent ac2271b commit 8b37bce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions unocss.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
import { defineConfig } from 'unocss'
import transformerDirectives from '@unocss/transformer-directives'
import { presetUni } from '@uni-helper/unocss-preset-uni'
import { presetApplet, presetRemRpx } from 'unocss-applet'
import { presetShades } from '@viarotel-org/unocss-preset-shades'
import presetWind from '@unocss/preset-wind'
import { primaryColor } from './src/configs/index.js'

const isApplet = process.env?.UNI_PLATFORM?.startsWith('mp-') ?? false

const presetMain = isApplet ? presetApplet() : presetWind()

const presets = [
presetUni({ attributify: false }),
presetMain,
presetShades(primaryColor),
presetRemRpx(),
]

export default defineConfig({
theme: {
colors: {
gray: presetMain?.theme?.colors?.neutral,
},
},
// @ts-ignore
presets,
theme: {},
transformers: [transformerDirectives()],

shortcuts: {
'inset-center':
'absolute top-1/2 left-1/2 transform -translate-y-1/2 -translate-x-1/2',
'inset-x-center': 'absolute left-1/2 transform -translate-x-1/2',
'inset-y-center': 'absolute top-1/2 transform -translate-y-1/2',
'h-safe-bottom': 'h-[constant(safe-area-inset-bottom)] h-[env(safe-area-inset-bottom)]',
},
})
3 changes: 2 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { homePage } from './src/configs/index.js'

const isDevelopment = process.env.NODE_ENV === 'development'
const isProduction = process.env.NODE_ENV === 'production'

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -27,8 +28,8 @@ export default defineConfig({
mergePages: false,
homePage,
}),
useRemoveConsole(),
useUni(),
...isProduction ? [useRemoveConsole()] : [],
],
server: {
cors: true,
Expand Down

0 comments on commit 8b37bce

Please sign in to comment.