#build #npm #front-end #react-scripts

build-my-react-js

Integrate your ReactJS with your Rust CI and build it

3 releases

0.1.8 Dec 19, 2024
0.1.7 Dec 19, 2024
0.1.6 Dec 19, 2024

#426 in Filesystem

Download history 297/week @ 2024-12-16 22/week @ 2024-12-23

319 downloads per month

MIT/Apache

12KB
146 lines

Build-my-react-js

For a subdirectory in your project, add this to your build.rs to recurse and build your node project on diverse systems with diverse configurations, possibly successfully.

This goes in your build script, for use with react-scripts, and cra template projects.

It can be helpful for both development and deployment.

So, as an example, with the directory structure like:

.
..
.gitignore
src/
my-frontend/
  src/
    index.js
    CookieNoticeConsent.js
    NotificationsApi.js
    [...]
  package.json
Cargo.toml
Cargo.lock
[...]

Add to your project as a build dependency,

cargo add --build build-my-react-js

Add this to a build.rs file:

// `build.rs`
use build_my_react_js::*;

fn main() {
    build_react_under!("my-frontend");
}

Effectively, will cause cargo, during dirty / new builds, it will go into the directory and do:

test -e my-frontend/build/index.html
npm ping    #only the first time
npm install #only the first time
npm ping
npm run build

It uses a cargo facility that tests for updates to my-frontend/src/* or my-frontend/package.json, and so usually only runs your react-scripts build if you have changed something.

Dependencies

~6KB