I want to write fast, reliable and efficient web apps. Quickly.
And I like Rust and documentation.
LIVE DEMO: seed-quickstart-webpack.netlify.com
Main components:
- Seed - Rust framework, inspired by Elm. Seed's Awesome list.
- Tailwind CSS - CSS framework. All CSS classes in your project are typed for safe use in Rust code. Unused classes are automatically deleted for much smaller bundle size.
- Webpack - Bundler. Auto-reload on code change, dev-server accessible from mobile phones, prerendering for static websites... and many more useful features are prepared for you in this quickstart.
- Production-ready starter project - Example project is based on the website with several pages, favicons, nice fonts, meta tags for social media, buttons for scrolling to top, header which is hidden on scrolling, etc. It can be prerendered, but it also contains loading screen. For more complex project (based on another quickstart) see seed-rs-realworld.
- Production-ready configuration - Project is linted, compiled, prerendered and deployed in CI pipeline (see
.travis.yml
andnetlify.toml
). Linters are very strict.
How to create your new app, modify it and deploy it - step by step guide.
I want to show you how to create, build and host your website for free, so we will need a public GitHub repository.
-
The simplest way how to do it is to click on the green button Use this template on the GitHub profile of this quickstart.
-
Clone your new repository to your local machine. I use GitKraken, but you are probably better developer than me - use your favorite terminal.
-
Make sure you have basic tools installed:
-
These tools are required by some commands:
-
- Check:
$ cargo make -V
=>cargo-make 0.22.1
- Install:
$ cargo install --force cargo-make
- Check:
-
- Check:
$ cargo +nightly fmt -- -V
=>rustfmt 1.4.8-nightly (afb1ee1c 2019-09-08)
- Install:
$ rustup toolchain install nightly
$ rustup component add rustfmt --toolchain nightly
- Check:
-
- Open terminal in your project and go to directory
crate
-$ cd crate
- Install Webpack and other dependencies -
$ yarn
- Try to start dev-server -
$ yarn start
- and then open localhost:8000 in a browser. - Stop server (try
Ctrl+c
). - Try to lint your project -
$ cargo make verify_only
- you shouldn't see any errors. - Modify files like
LICENCE
,README.md
and/crate/Cargo.toml
as you wish and push changes into GitHub.
- Open project in your favorite IDE. I use IntelliJ or VS Code.
- Run
$ yarn start
in terminal. I usebash
integrated into IDE (it's installed with Git on Windows).- Note: Yarn commands can be run from project root or from directory
crate
, but Cargo commands can be run only fromcrate
.
- Note: Yarn commands can be run from project root or from directory
- Open localhost:8000 in a browser.
- You can open it also in your mobile phone:
- Make sure your dev-server aka computer is in the same network as your phone.
- Find out your local IP address. Use e.g. this online tool: https://www.whatismybrowser.com/detect/what-is-my-local-ip-address.
- Open URL with found IP address and default port (e.g.
192.168.1.5:8000
) on your phone.
Note: You don't have to follow all steps below - reuse starter project code as you need.
- Open
/crate/src/page/partial/header.rs
in your IDE. - Delete function
header_visibility
. - Write a new body for function
view
.
- Open
/crate/src/page/partial/footer.rs
in your IDE. - Write a new body for function
view
.
- Open
/crate/src/page/not_found.rs
in your IDE. - Write a new body for function
view
.
- Open
/crate/src/page/home.rs
in your IDE. - Write a new body for function
view
.
- Open
/crate/src/page/about.rs
in your IDE. - Write a new body for function
view
.
- Open
/crate/src/lib.rs
in your IDE. - Change
TITLE_SUFFIX
value. - Delete
MAIL_TO_KAVIK
andMAIL_TO_HELLWEB
. - Write a new body for function
view
.
- Delete or replace files in
/favicons
. - Open
/entries/templates/favicons.hbs
in your IDE. - Delete content or update it.
- Note: Templates are written in Handlebars.
- Open
/entries/templates/loading_page.hbs
in your IDE. - Delete content or update it.
- Open
/entries/templates/social_media.hbs
in your IDE. - Delete content or update it.
- Open
/entries/index.hbs
in your IDE. - Update content.
- Delete or replace files and directories in
/static/fonts
. - Open
/css/fonts.css
in your IDE. - Delete content or update it.
- Delete or replace files in
/static/images
. - Delete
/static/Martin_Kavik_resume.pdf
.
- Open
/configs/tailwind.config.js
in your IDE. - Update content or replace it with the default one:
module.exports = {
theme: {},
variants: {},
plugins: []
};
- Open
/css/custom.css
in your IDE. - Delete content or update it.
How to format, lint and test your project.
And how to setup Travis CI pipeline with deploy into Netlify.
- Format:
$ cargo make fmt
(it overwrites files) or only$ cargo make fmt_check
- You can modify format settings in:
/crate/rustfmt.toml
/crate/Makefile.toml
- tasksfmt
andfmt_check
- Lint:
$ cargo make clippy
- You can modify linter settings in:
/crate/Makefile.toml
- taskclippy
- Run
$ cargo make test_h firefox
for headless testing in Firefox.- There are more similar commands - see
/crate/Makefile.toml
- Note: There is only one test in this project (
crate/tests/test.rs
), see seed-rs-realworld for more examples.
- There are more similar commands - see
- If you want to test prerendered website:
$ yarn build:prerender
$ serve:dist
- Open localhost:8000 in a browser.
- Tip: Always test it also in production environment because e.g. routing is a little bit different among servers.
- Always run
$ cargo make verify
before push to make sure CI pipeline will accept your code.- It'll format your code, lint it and start headless tests in Firefox.
- You can change its behaviour in
/crate/Makefile.tom
- taskverify
(similar taskverify_only
is used in CI).
- Create a new Netlify site.
- [Optional] Change site name or/and use your own domain.
- [Optional] Turn on HTTPS.
- [Optional] Add badge to project's
/README.md
(Site detail >Settings
>General
>Status badges
). - Note somewhere Site id (Site detail >
Settings
>General
> API ID) - Create and note somewhere Access token (Click on your avatar >
User settings
>Applications
>New access token
> Name it for instanceTravisCI
) - [Optional] Adjust
/netlify.toml
to suit your needs. Netlify docs.
- Sync your TravisCI account with your GitHub one.
- Find repository with your app in your list and click on
Settings
. - Add Environment Variable
NETLIFY_SITE_ID
and set it's value to Site id. - Add Environment Variable
NETLIFY_ACCESS_TOKEN
and set it's value to Access token. - Switch to tab
Current
and clickActivate repository
. - [Optional] Add badge to project's
/README.md
(Repository detail > Click on badge next to the rep. name >IMAGE URL
change toMARKDOWN
) - [Optional] Modify
/.travis.yml
.- Replace
yarn build:prerender
withyarn build:release
if you don't want to prerender pages. - Tip: If jobs don't want to start after push, check Repository detail >
More options
>Requests
.
- Replace
- Create PR or issue in awesome-seed-rs.
- MartinKavik/kavik.cz
- [create PR or Issue]
- Improved documentation, fixed typos, updated dependencies, ... - create Issue or PR.
- Ideas, bugs, questions, ... - create Issue.
Note: Please squash commits and rebase before creating PR. Thanks!