Skip to content

Commit 17c6402

Browse files
committed
Add FileMap
1 parent 2247d57 commit 17c6402

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/webpack-plugin/src/loader.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { writeFile } from 'node:fs/promises'
22
import { basename, dirname, join, relative } from 'node:path'
33

4-
import { codeExtract, exportClassMap, exportSheet } from '@devup-ui/wasm'
4+
import {
5+
codeExtract,
6+
exportClassMap,
7+
exportFileMap,
8+
exportSheet,
9+
} from '@devup-ui/wasm'
510
import type { RawLoaderDefinitionFunction } from 'webpack'
611

712
export interface DevupUILoaderOptions {
@@ -21,6 +26,7 @@ const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions> =
2126
cssDir,
2227
sheetFile,
2328
classMapFile,
29+
fileMapFile,
2430
splitCss,
2531
} = this.getOptions()
2632
const callback = this.async()
@@ -52,6 +58,7 @@ const devupUILoader: RawLoaderDefinitionFunction<DevupUILoaderOptions> =
5258
),
5359
watch ? writeFile(sheetFile, exportSheet()) : null,
5460
watch ? writeFile(classMapFile, exportClassMap()) : null,
61+
watch ? writeFile(fileMapFile, exportFileMap()) : null,
5562
])
5663
.catch(console.error)
5764
.finally(() => callback(null, code, sourceMap))

packages/webpack-plugin/src/plugin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getDefaultTheme,
1414
getThemeInterface,
1515
importClassMap,
16+
importFileMap,
1617
importSheet,
1718
registerTheme,
1819
setDebug,
@@ -96,13 +97,16 @@ export class DevupUIWebpackPlugin {
9697

9798
const sheetFile = join(this.options.interfacePath, 'sheet.json')
9899
const classMapFile = join(this.options.interfacePath, 'classMap.json')
100+
const fileMapFile = join(this.options.interfacePath, 'fileMap.json')
99101
if (this.options.watch) {
100102
try {
101103
// load sheet
102104
if (existsSync(sheetFile))
103105
importSheet(JSON.parse(readFileSync(sheetFile, 'utf-8')))
104106
if (existsSync(classMapFile))
105107
importClassMap(JSON.parse(readFileSync(classMapFile, 'utf-8')))
108+
if (existsSync(fileMapFile))
109+
importFileMap(JSON.parse(readFileSync(fileMapFile, 'utf-8')))
106110
} catch (error) {
107111
console.error(error)
108112
}
@@ -177,6 +181,7 @@ export class DevupUIWebpackPlugin {
177181
cssDir: this.options.cssDir,
178182
sheetFile,
179183
classMapFile,
184+
fileMapFile,
180185
watch: this.options.watch,
181186
splitCss: this.options.splitCss,
182187
},

0 commit comments

Comments
 (0)