Skip to content

Commit 6f4f64b

Browse files
authored
fix: remove css dependency to dedent (#64)
* remove css dependency to dedent * feat: merge configs when passing a config * fix: allow merge config for css
1 parent 23e6eeb commit 6f4f64b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.changeset/early-weeks-tap.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@cypress-design/css': patch
3+
---
4+
5+
- remove dependency of @cypress-design/css to `dedent`
6+
- merge the windicss config passed to plugins with the default config

css/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { UserOptions } from 'vite-plugin-windicss'
33
import VitePlugin from 'vite-plugin-windicss'
44
import WebpackPlugin from 'windicss-webpack-plugin'
55
import windiConfig from './windi.config'
6+
import { merge } from 'lodash'
67

78
function getConfig(options: UserOptions) {
89
const scan = typeof options.scan === 'boolean' ? {} : options.scan ?? {}
@@ -17,8 +18,8 @@ function getConfig(options: UserOptions) {
1718
)
1819

1920
return {
20-
config: windiConfig,
2121
...options,
22+
config: merge(windiConfig, options.config),
2223
scan: {
2324
...(scan || {}),
2425
include: [

css/src/windi-keep-rollup-plugin.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from 'vite-plugin-windicss'
77
import { IconExtractor } from './icon-color-plugins'
88
import windiConfig from './windi.config'
9-
import dedent from 'dedent'
109

1110
export default function WindiKeepRollupPlugin(): Plugin {
1211
const classSet = new Set<string>()
@@ -39,9 +38,7 @@ export default function WindiKeepRollupPlugin(): Plugin {
3938
await utils.ensureInit()
4039
const { success } = utils.processor.interpret([...classSet].join(' '))
4140
if (chunk?.type === 'chunk') {
42-
chunk.code += dedent`
43-
/* <windicss-keep class="${success.join(' ')}"> */
44-
\n`
41+
chunk.code += `\n/* <windicss-keep class="${success.join(' ')}"> */\n`
4542
}
4643
},
4744
}

0 commit comments

Comments
 (0)