https://github.com/8176135/inline-assets-rs
A Rust library for inlining Javascript, CSS, and font files into your html files for easy distribution.
https://github.com/8176135/inline-assets-rs
inline-assets inline-css inline-javascript library rust
Last synced: 4 months ago
JSON representation
A Rust library for inlining Javascript, CSS, and font files into your html files for easy distribution.
- Host: GitHub
- URL: https://github.com/8176135/inline-assets-rs
- Owner: 8176135
- License: mit
- Created: 2018-07-02T02:54:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-19T04:49:59.000Z (over 4 years ago)
- Last Synced: 2025-08-15T01:44:06.628Z (11 months ago)
- Topics: inline-assets, inline-css, inline-javascript, library, rust
- Language: Rust
- Size: 432 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
inline-assets-rs
=====
[](https://travis-ci.org/Hand-of-Cthulhu/inline-assets-rs)
[](https://crates.io/crates/inline-assets)
[](https://docs.rs/inline_assets/)
[](https://raw.githubusercontent.com/Hand-of-Cthulhu/inline-assets-rs/master/LICENSE)
A Rust library for inlining Javascript, CSS, and font files into your html files for easy distribution.
This also changes `url(local_path)` in the css to be relative to the html file.
Originally intended to be used in build scripts of [web_view](https://github.com/Boscop/web-view "Rust bindings to zserge/webview") projects.
The output can also be able to be piped into [minifier-rs](https://github.com/GuillaumeGomez/minifier-rs) to save space.
### Usage:
Usage is really simple, just call `inline_assets::inline_html_string(file_path, inline_assets::Config::default())`, with the html file path.
The config currently provides 2 options (with the default being both enabled):
* `inline_fonts`: Whether or not to inline fonts in the css as base64.
* `remove_new_lines`: Replace `\r` and `\r\n` with a space character. Useful to keep line numbers the same in the output to help with debugging.
Look in the example folder for a CLI binary example.
All font files should work if font format is set correctly. i.e.`src: url(font-file) format(font-format)`
To import CSS recursively, use `@import url(path_to_another_css_file);` in your css files. Multiple imports of the same CSS file will only be imported once.
### TODO:
* Support inlining images