Skip to content

Commit 5a2ab9d

Browse files
committed
Fix webpack issue
1 parent 4b0038c commit 5a2ab9d

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

.changeset/modern-bats-decide.md

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

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
} from 'node:fs'
88
import { join, resolve } from 'node:path'
99

10-
import { getCss, getThemeInterface, registerTheme } from '@devup-ui/wasm'
10+
import {
11+
getCss,
12+
getDefaultTheme,
13+
getThemeInterface,
14+
registerTheme,
15+
} from '@devup-ui/wasm'
1116
import { describe } from 'vitest'
1217

1318
import { DevupUIWebpackPlugin } from '../plugin'
@@ -113,8 +118,11 @@ describe('devupUIPlugin', () => {
113118
tapAsync: vi.fn(),
114119
},
115120
},
116-
}
117-
plugin.apply(compiler as any)
121+
webpack: {
122+
DefinePlugin: vi.fn(),
123+
},
124+
} as any
125+
plugin.apply(compiler)
118126
// asyncCompile
119127
const add = vi.fn()
120128
vi.mocked(compiler.hooks.afterCompile.tap).mock.calls[0][1]({
@@ -151,6 +159,9 @@ describe('devupUIPlugin', () => {
151159
tapAsync: vi.fn(),
152160
},
153161
},
162+
webpack: {
163+
DefinePlugin: vi.fn(),
164+
},
154165
} as any)
155166

156167
expect(writeFileSync).toHaveBeenCalledWith('css', '', {
@@ -184,6 +195,9 @@ describe('devupUIPlugin', () => {
184195
tapAsync: vi.fn(),
185196
},
186197
},
198+
webpack: {
199+
DefinePlugin: vi.fn(),
200+
},
187201
} as any
188202
plugin.apply(compiler)
189203

@@ -214,6 +228,9 @@ describe('devupUIPlugin', () => {
214228
tapAsync: vi.fn(),
215229
},
216230
},
231+
webpack: {
232+
DefinePlugin: vi.fn(),
233+
},
217234
} as any
218235
vi.mocked(existsSync).mockReturnValue(true)
219236
plugin.apply(compiler)
@@ -297,6 +314,9 @@ describe('devupUIPlugin', () => {
297314
tapAsync: vi.fn(),
298315
},
299316
},
317+
webpack: {
318+
DefinePlugin: vi.fn(),
319+
},
300320
} as any
301321
plugin.apply(compiler)
302322

@@ -307,5 +327,8 @@ describe('devupUIPlugin', () => {
307327
encoding: 'utf-8',
308328
},
309329
)
330+
expect(compiler.webpack.DefinePlugin).toHaveBeenCalledWith({
331+
'process.env.DEVUP_UI_DEFAULT_THEME': JSON.stringify(getDefaultTheme()),
332+
})
310333
})
311334
})

0 commit comments

Comments
 (0)