Skip to content

Commit 2edb047

Browse files
committed
Fix FileMap
1 parent 17c6402 commit 2edb047

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/devup-ui-wasm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ once_cell = "1.21.3"
2929
js-sys = "0.3.77"
3030
serde_json = "1.0.143"
3131
serde-wasm-bindgen = "0.6.5"
32+
bimap = { version = "0.6.3", features = ["serde"] }
3233

3334
[dev-dependencies]
3435
wasm-bindgen-test = "0.3.50"

bindings/devup-ui-wasm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use css::class_map::{get_class_map, set_class_map};
2-
use css::file_map::{get_file_map, get_filename_by_file_num};
2+
use css::file_map::{get_file_map, get_filename_by_file_num, set_file_map};
33
use extractor::extract_style::ExtractStyleProperty;
44
use extractor::extract_style::extract_style_value::ExtractStyleValue;
55
use extractor::extract_style::style_property::StyleProperty;
@@ -223,7 +223,7 @@ pub fn export_class_map() -> Result<String, JsValue> {
223223

224224
#[wasm_bindgen(js_name = "importFileMap")]
225225
pub fn import_file_map(sheet_object: JsValue) -> Result<(), JsValue> {
226-
set_class_map(
226+
set_file_map(
227227
serde_wasm_bindgen::from_value(sheet_object)
228228
.map_err(|e| JsValue::from_str(e.to_string().as_str()))?,
229229
);

libs/css/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ phf = { version = "0.13", features = ["macros"] }
99
serial_test = "3.2.0"
1010
serde = { version = "1.0.219", features = ["derive"] }
1111
regex = "1.11.2"
12-
bimap = { version = "0.6.3", features = ["serde"] }
12+
bimap = { version = "0.6.3" }
1313

1414
[dev-dependencies]
1515
rstest = "0.26.1"

packages/webpack-plugin/src/loader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface DevupUILoaderOptions {
1414
cssDir: string
1515
sheetFile: string
1616
classMapFile: string
17+
fileMapFile: string
1718
watch: boolean
1819
splitCss: boolean
1920
}

packages/webpack-plugin/src/plugin.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ export class DevupUIWebpackPlugin {
7777
)
7878
}
7979

80-
if (this.options.watch && !existsSync(this.options.cssDir)) {
80+
if (!existsSync(this.options.cssDir))
8181
mkdirSync(this.options.cssDir, { recursive: true })
82-
writeFileSync(join(this.options.cssDir, 'devup-ui.css'), '')
83-
}
82+
if (this.options.watch)
83+
writeFileSync(join(this.options.cssDir, 'devup-ui.css'), getCss(), {
84+
encoding: 'utf-8',
85+
})
8486
}
8587

8688
apply(compiler: Compiler) {
@@ -141,10 +143,13 @@ export class DevupUIWebpackPlugin {
141143
compilation.fileDependencies.add(resolve(this.options.devupPath))
142144
})
143145
}
144-
if (!existsSync(this.options.cssDir)) {
146+
if (!existsSync(this.options.cssDir))
145147
mkdirSync(this.options.cssDir, { recursive: true })
146-
writeFileSync(join(this.options.cssDir, 'devup-ui.css'), '')
147-
}
148+
149+
if (this.options.watch)
150+
writeFileSync(join(this.options.cssDir, 'devup-ui.css'), getCss(), {
151+
encoding: 'utf-8',
152+
})
148153

149154
compiler.options.plugins.push(
150155
new compiler.webpack.DefinePlugin({

0 commit comments

Comments
 (0)