Vite / HMR Integration
The included demo/ directory is a working example of Vite integration with SCSS and React.
How it works
- Set
devResourcesUrlin config:"http://localhost:5173/" - In
theme.properties, reference source files directly:styles=css/login.css src/theme.scss - Fitcloak proxies
/resources/*,/src/*,/@*,/node_modules/*to the Vite dev server - Vite compiles SCSS, JSX, TypeScript (or other preprocessors) on the fly
- Falls back to local files if the dev server is unavailable
Using with your own theme
Set up a Vite project in your theme directory with SCSS/PostCSS/etc., reference source files in theme.properties, and point devResourcesUrl to Vite.
Example: adding SCSS
cd your-theme
npm init -y
npm install --save-dev vite sass
Create vite.config.js:
import { defineConfig } from 'vite'
export default defineConfig({
root: '.',
})
Reference SCSS in login/theme.properties:
parent=keycloak
styles=css/login.css src/theme.scss
Example: adding React
The demo theme shows this pattern — see demo/src/PasswordStrength.jsx for a React component that enhances the login page. The key is using <script type="module"> in your custom .ftl template instead of the standard properties.scripts mechanism.