Make sure you have wasm-pack installed.
Install Dependencies
cargo build We are using Workspaces, so you can add a new component by running:
cargo new components/NAME_OF_COMPONENT --lib Make sure to add this snippet to the Cargo.toml file for each new component setup.
[lib] crate-type = ["cdylib", "rlib"] [dependencies] custom-elements = { workspace = true } wasm-bindgen.workspace = true web-sys = { version = "0.3", features = [ "Window", "Document", "HtmlElement", "Node", "Text" ]}To build your web components (before running the dev server), run:
NOTE: each component has its own build command. It might be smart to write a script that builds all of the components in one go?
wasm-pack build --target=web --out-dir '../../pkg/NAME_OF_COMPONENT' components/NAME_OF_COMPONENT Install microserver and then run it from the root of the project.
microserver -a 127.0.0.1 -p 3000 This will serve up the index.html file at localhost:3000
NOTE: you can use any other tool to serve up the
index.htmlfile locally