MightyMeld Prefab Setup
Setting Up Prefabs
Read about prefabs and how they are useful in MightyMeld.
Video Setup Guide
Adding Prefabs to Your Project
Create a directory to store your prefabs in. For example,
src/prefabs
.Tell MightyMeld where to find your prefabs:
mightymeld.json{
"include": ...
"run": ...
...
"prefab_dir": "src/prefabs",
...
}Add some prefab files to the directory you created above. Prefabs are ordinary JSX or TSX files that contain template components. See the next section for examples.
Add and commit the prefab file(s) to your git repostory.
Restart MightyMeld (stop and start
npx mightymeld
) for the new config to take effect.Reload MightyMeld studio in your browser. You’ll find the new prefabs in the library panel.
Off the Shelf Prefabs
We maintain a library of prefabs that you can use in your project.
Some you might be interested in:
Creating Your Own Prefabs
Prefabs are just ordinary JSX files that contain template components. Here’s an example:
import { Alert, AlertTitle } from '@mui/material';
// Will be named `Alert with title` in MightyMeld studio
export const _Alert_with_title = () => (
<Alert severity="warning">
<AlertTitle>Title</AlertTitle>
Description
</Alert>
);
Customizing prefabs is as easy as editing these simple components. To see the changes in Studio, just refresh your browser.
To learn more about the prefab file format, see the repository README.