2021ai-grace-app
v1.0.0
Published
Use this package to build your React app to work in Grace environment.
Downloads
162
Readme
Grace-app
Use this package to build your React app to work in Grace environment.
Usage
Install 2021ai-grace-app
in your project:yarn add 2021ai-grace-app
Make sure you have peer dependencies installed in your project:
"axios": "^1.4.0",
"react": "^18.2.0"
Make sure to have src/App.jsx
file, which exports a React component called App.
2021ai-grace-app serve
to run app your app in development mode
2021ai-grace-app build
to build your app to production
Grace app loads a config file in run-time. The config.json
file is expected to be located in the parent directory
relative to grace-app
. Currently following properties are defined:
apiPath
- the url pointing to client's application backend API
In your React app you can use:useGraceContext
- a hook that would return following object:
{
config: {
apiPath: string
}
}
example:
const { config } = useGraceContext();
console.log(config.apiPath);
Webpack configuration
The library comes with some default webpack configs, which are used when serving or building the app
with 2021ai-grace-app
CLI commands. These configs provide basic support for react apps. If your project requires
additional webpack configuration, all you need to do is to create files in the main project folder:
webpack.config.js
for any shared configwebpack.dev.config.js
for any config used by2021ai-grace-app serve
commandwebpack.prod.config.js
for any config used by2021ai-grace-app build
command
The serve command will take libraries webpack.dev.config.js
, extend it with your webpack.config.js
and then extend
it with your webpack.dev.config.js
The build command will take libraries webpack.prod.config.js
, extend it with your webpack.config.js
and then extend
it with your webpack.prod.config.js
For developers of Grace-app
This node package provides cli commands to enable Grace users to build their React apps. We wrap the provided app in our
code as defined in src/index.js
. The wrapping script can be found under scripts/wrap.js
.
To start working with this project:
- install node
- install yarn
- in workspace run
yarn install
- make you changes
- make sure you have 2021AI auth token to npmjs
- run
yarn build
andyarn npm publish
. Remember to bump version in package.json.
In development, you can use local node registry like Verdaccio to publish this package. If you do, point to your local registry in .yarnrc.yml in workspace main path.
You can use my-app in this workspace (in the parent folder) to test grace-app
as a dependency.