New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📝(website) document the frontend build for dependents #887
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
id: building-the-frontend | ||
title: Building Richie's frontend in your own project | ||
sidebar_label: Building the frontend | ||
--- | ||
|
||
Richie offers plenty of opportunities to customize the way it works and make it suit the needs of your own project. Most of these go through Django settings. | ||
|
||
Part of Richie is a React frontend however. If you want to change how it works in ways that cannot be changed from the Django settings, you will need to build your own frontend. | ||
|
||
## Installing `richie-education` | ||
|
||
If you have not already, you should create a directory for the frontend in your project. We recommend you mirror Richie's file structure so it's easier to keep track of the changes you make. | ||
|
||
```bash | ||
mkdir -p src/frontend | ||
``` | ||
|
||
Then, you need to bootstrap your own frontend project in this new directory. | ||
|
||
```bash | ||
cd src/frontend | ||
yarn init | ||
``` | ||
|
||
With each version of Richie, we build and publish an `NPM` package to enable Richie users to build their own Javascript and CSS. You're now ready to install it. | ||
|
||
```bash | ||
yarn add richie-education | ||
``` | ||
|
||
In your `package.json` file, you should see it in the list of dependencies. Also, there's a `node_modules` directory where the package and its dependencies are actually installed. | ||
|
||
```json | ||
"dependencies": { | ||
"richie-education": "1.12.0" | ||
}, | ||
``` | ||
|
||
## Building the Javascript bundle | ||
|
||
You are now ready to run your own frontend build. We'll just be using webpack directly. | ||
|
||
```bash | ||
yarn webpack --config node_modules/richie-education/webpack.config.js --output-path ./build --richie-dependent-build | ||
``` | ||
|
||
Here is everything that is happening: | ||
|
||
- `yarn webpack` — run the webpack CLI; | ||
- `--config node_modules/richie-education/webpack.config.js` — point webpack to `richie-education`'s webpack config file; | ||
- `--output-path ./build` — make sure we get our output where we need it to be; | ||
- `--richie-dependent-build` — enable some affordances with import paths. We pre-configured Richie's webpack to be able to run it from a dependent project. | ||
|
||
You can now run your build to change frontend settings or override frontend components with your own. | ||
|
||
## Building the CSS | ||
|
||
If you want to change styles in Richie, or add new styles for components & templates you develop yourself, you can run the SASS/CSS build yourself. | ||
|
||
Start by creating your own `main` file. The `_` underscore at the beginning is there to prevent sass from auto-compiling the file. | ||
|
||
```bash | ||
mkdir -p src/frontend/scss | ||
touch src/frontend/scss/_mains.scss | ||
``` | ||
|
||
Start by importing Richie's main scss file. If you prefer, you can also directly import any files you want to include — in effect re-doing Richie's `_main.scss` on your own. | ||
|
||
```sass | ||
@import "richie-education/scss/main"; | ||
``` | ||
|
||
You are now ready to run the CSS build: | ||
|
||
``` | ||
cd src/frontend | ||
yarn sass | ||
``` | ||
|
||
This gives you one output CSS file that you can put in the static files directory of your project and use to override Richie's style or add your own parts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should maybe start a multi-line array ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's
prettier
's job 😇There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the CI runs prettier in the
website
directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, and we should probably add it. I was just saying in this instance I formatted with
prettier
and it does not put a newline hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done #893