Rewritten version of the CTFd core theme to use Bootstrap 5, Alpine.js, and vite to improve upon the existing CTFd theme structure.
git subtree add --prefix CTFd/themes/core-beta [email protected]:CTFd/core-beta.git main --squash
git subtree pull --prefix CTFd/themes/core-beta [email protected]:CTFd/core-beta.git main --squash
Make sure to use Merge Commits when dealing with the subtree here. For some reason Github's squash and commit uses the wrong line ending which causes issues with the subtree script: https://stackoverflow.com/a/47190256.
To create a custom theme based on the core-beta one, here are the steps to follow:
-
Clone core-beta theme locally to a seperate folder
git clone https://github.com/CTFd/core-beta.git custom-themeTo clarify the structure of the project, the
./assetsfolder contains the uncompiled source files (the ones you can modify), while the./staticdirectory contains the compiled ones. -
Install Yarn following the official installation guides.
- Yarn is a dependency management tool used to install and manage project packages
- Vite handles the frontend tooling in CTFd by building optimized assets that are served through Flask.
-
Run
yarn installin the root ofcustom-themefolder to install the necessary Node packages includingvite. -
Run the appropriate yarn build mode:
- Run
yarn dev(this will runvite build --watch) while developing the theme. - Run
yarn build(which will runvite build) for a one-time build. Vite allows you to preview changes instantly with hot reloading.
- Run
-
Now, you can start your modifications in the
assetsfolder. Each time you save, Vite will automatically recompile everything (assuming you are usingyarn dev), and you can directly see the result by importing your compiled theme into a CTFd instance. Note: You do not need thenode_modulesfolder, you can simply zip the theme directory without it. -
When you are ready you can use
yarn buildto build the production copy of your theme.
- Document how we are using Vite
- Create a cookie cutter template package to use with Vite