CroftSoft / Library / Tutorials

Rust Wasm Project Setup


David Wallace Croft

  1. Install git
  2. Install Rust
  3. Install Visual Studio Code (VS Code)
  4. Install the following VS Code extensions

  5. Install node.js
  6. Initialize your project directory using the rust-webpack-template: npm init rust-webpack project-name cd project-name code .
  7. Test your setup cd project-name/ npm run build npm start
  8. Verify that "Hello world!" is showing in your browser console
  9. Update the properties in the package section of your Cargo manifest file Cargo.toml [package] name = "project-name" version = "0.1.0" authors = ["David Wallace Croft <>"] # Use the categories from categories = ["wasm"] description = "project description" edition = "2021" homepage = "" keywords = ["keyword"] # Remark this line out if your project is not open source license = "MIT" # Remark this line out when you publish to publish = false readme = "" # Remark this line out if your project is not in a code repository repository = ""
  10. Unremark the wee-alloc feature [features] # If you uncomment this line, it will enable `wee_alloc`: default = ["wee_alloc"]
  11. Customize the file in your project root directory # Project Name - Project description ## Usage - cd project-name/ - npm run build - npm start ## History - Initial release: YYYY-MM-DD
  12. Make a rustfmt.toml in your project root directory # array_width = 1 # blank_lines_lower_bound = 1 chain_width = 80 fn_args_layout = "Vertical" # group_imports = "StdExternalCrate" hard_tabs = false # imports_layout = "HorizontalVertical" match_block_trailing_comma = true # max_width = 80 merge_derives = true newline_style = "Unix" remove_nested_parens = true reorder_imports = true reorder_modules = true single_line_if_else_max_width = 0 struct_lit_width = 0 struct_variant_width = 0 tab_spaces = 2 use_try_shorthand = true # version = "Two" # wrap_comments = true
  13. If your project is open source, make a LICENSE.txt file MIT License Copyright (c) [year] [copyright-holder-name] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  14. Update the properties in the package.json file: { "name": "project-name", "version": "0.1.0", "author": ""David Wallace Croft <>"", "description": "[...]", "scripts": { [...] }, "devDependencies": { [...] } }
  15. Change the title in index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> Project Name </title> </head> <body> <noscript> Enable JavaScript in your browser to view the content of this webpage. </noscript> <script src="./bootstrap.js"> </script> </body> </html>
  16. Commit your code changes and push the commit to your code repository

© 2022 CroftSoft Inc

- Books
- Code
- Courses
- Links
- Media
- Software
- Tutorials
CroftSoft Web