Skip to content

Commit 858fa66

Browse files
authored
Merge pull request #146 from dev-five-git/fix-build-issue
Fix extract issue
2 parents 60cfcc9 + 18aa41b commit 858fa66

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.changeset/open-hotels-dress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/vite-plugin": patch
3+
---
4+
5+
Fix extract issue

packages/vite-plugin/src/__tests__/plugin.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,15 @@ describe('devupUIPlugin', () => {
322322
.config()
323323
.build.rollupOptions.output.manualChunks('devup-ui.css?v=1', 'code'),
324324
).toEqual('devup-ui.css')
325+
326+
const plugin1 = DevupUI({
327+
package: libPackage,
328+
cssFile,
329+
devupPath,
330+
interfacePath,
331+
extractCss: false,
332+
})
333+
expect((plugin1 as any).config().build).toBeUndefined()
325334
})
326335
it('should resolveId', () => {
327336
expect((plugin as any).resolveId('code', 'code')).toBeUndefined()

packages/vite-plugin/src/plugin.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
registerTheme,
99
setDebug,
1010
} from '@devup-ui/wasm'
11-
import { normalizePath, type PluginOption } from 'vite'
11+
import { normalizePath, type PluginOption, type UserConfig } from 'vite'
1212

1313
export interface DevupUIPluginOptions {
1414
package: string
@@ -69,13 +69,15 @@ export function DevupUI({
6969
return {
7070
name: 'devup-ui',
7171
config() {
72-
return {
72+
const ret: Omit<UserConfig, 'plugins'> = {
7373
server: {
7474
watch: {
7575
ignored: [`!${devupPath}`],
7676
},
7777
},
78-
build: {
78+
}
79+
if (extractCss) {
80+
ret['build'] = {
7981
rollupOptions: {
8082
output: {
8183
manualChunks(id) {
@@ -86,8 +88,9 @@ export function DevupUI({
8688
},
8789
},
8890
},
89-
},
91+
}
9092
}
93+
return ret
9194
},
9295
apply() {
9396
return true

0 commit comments

Comments
 (0)