Skip to content

Commit 2f95397

Browse files
author
Michael Bryan
authored
Merge pull request wasmerio#380 from wasmerio/auto-build-markdown-renderer
Wire up `vite.config.js` to automatically compile the `markdown-renderer` crate
2 parents 02d78bf + f9986f6 commit 2f95397

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

.github/workflows/ci.yml

-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ jobs:
7070
- name: Build the Markdown Editor Example
7171
run: |
7272
npm install
73-
pushd markdown-renderer
74-
cargo build --release --target=wasm32-wasi
75-
popd
7673
npm run build
7774
working-directory: "examples/markdown-editor"
7875
- name: Build the (Improved) Markdown Editor Example

examples/markdown-editor/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"compilerOptions": {
33
"lib": [
44
"DOM"
5-
]
5+
],
6+
"target": "ES2017",
7+
"module": "ESNext",
8+
"moduleResolution": "Bundler"
69
}
710
}

examples/markdown-editor/vite.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from "vite";
2+
import { exec } from "node:child_process";
23

34
export default defineConfig({
45
server: {
@@ -7,5 +8,26 @@ export default defineConfig({
78
"Cross-Origin-Embedder-Policy": "require-corp",
89
},
910
},
11+
plugins: [
12+
{
13+
name: "cargo-build",
14+
buildStart: () => {
15+
return new Promise((resolve, reject) => {
16+
exec(
17+
"cargo build --target=wasm32-wasi --manifest-path=markdown-renderer/Cargo.toml --release --quiet",
18+
(err, stdout, stderr) => {
19+
if (err) {
20+
console.log("Stdout:", stdout);
21+
console.log("Stderr:", stderr);
22+
reject(err);
23+
} else {
24+
resolve();
25+
}
26+
}
27+
);
28+
});
29+
}
30+
},
31+
]
1032
});
1133

0 commit comments

Comments
 (0)