Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Replace Snowpack with Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops committed Jul 25, 2022
1 parent c73c3ee commit 5fa63d9
Show file tree
Hide file tree
Showing 25 changed files with 12,376 additions and 21,735 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
@@ -1,7 +1,7 @@
/** @type {import("eslint").Linter.Config } */
module.exports = {
root: true,
ignorePatterns: ["node_modules", "build", "keycloak-theme", "server"],
ignorePatterns: ["node_modules", "dist", "keycloak-theme", "server"],
parserOptions: {
project: "./tsconfig.eslint.json",
extraFileExtensions: [".mjs"],
Expand Down
152 changes: 22 additions & 130 deletions .gitignore
@@ -1,143 +1,35 @@

# Created by https://www.gitignore.io/api/node,react
# Edit at https://www.gitignore.io/?templates=node,react

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
node_modules
dist
dist-ssr
*.local

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Cypress
assets
**/cypress.env.json
cypress/downloads

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# Yarn lockfile
yarn.lock

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# rollup.js default build output
dist/
lib/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Temporary folders
tmp/
temp/

### react ###
.DS_*
**/*.backup.*
**/*.back.*

**/node_modules

*.sublime*

psd
thumb
sketch

# End of https://www.gitignore.io/api/node,react

# snowpack
.snowpack
build/

# server-install
server/

# VS Code #
###########
**/*.code-workspace

# Cypress #
###########
/assets
**/cypress.env.json
cypress/downloads/

# IntelliJ #

*.iml
.idea
# Keycloak server
server
34 changes: 2 additions & 32 deletions README.md
Expand Up @@ -44,12 +44,12 @@ You'll only have to run this command once, unless you remove the server director

### Running the development server

Now that the Keycloak sever is running it's time to run the development server for the Admin UI. This server is used to build the Admin UI in a manner that it can be iterated on quickly in a browser, using features such as [Hot Module Replacement (HMR) and Fast Refresh](https://www.snowpack.dev/concepts/hot-module-replacement).
Now that the Keycloak sever is running it's time to run the development server for the Admin UI. This server is used to build the Admin UI in a manner that it can be iterated on quickly in a browser, using features such as [Hot Module Replacement (HMR)](https://vitejs.dev/guide/features.html#hot-module-replacement) and [Fast Refresh](https://www.npmjs.com/package/react-refresh).

To start the development server run the following command:

```bash
npm run start
npm run dev
```

Once the process of optimization is done your browser will automatically open your local host on port `8080`. From here you will be redirected to the Keycloak server to authenticate, which you can do with the default username and password (`admin`).
Expand All @@ -68,36 +68,6 @@ Every time you create a commit it should be automatically linted and formatted f
npm run lint
```

## Theming

It's possible to theme the Admin UI interface, this is useful if you want to apply your own branding so that the product looks familiar to your users. The Admin UI comes with two built-in themes called `keycloak` and `rh-sso`, by default the `keycloak` theme will be used when building the application.

This behavior can be changed by passing in a `THEME_NAME` environment variable, for example if wanted to build the application using the `rh-sso` theme we can do the following:

```bash
THEME_NAME=rh-sso npm run build
```

And likewise if we wanted to start a development server with this theme:

```
THEME_NAME=rh-sso npm run start
```

To make it simpler to build the `rh-sso` theme there are some shorthand NPM scripts available that you can run instead:

```bash
# Run a production build with the 'rh-sso' theme
npm run build:rh-sso

# Or for development
npm run start:rh-sso
```

### Creating your own theme

All themes are located in the `themes/` directory of the project, if you want to create a new theme you can create a new directory here and name it the same as your theme. Copy the files from the default theme here and customize them to your liking.

## Integration testing with Cypress

This repository contains integration tests developed with the [Cypress framework](https://www.cypress.io/).
Expand Down
1 change: 1 addition & 0 deletions cypress/tsconfig.json
Expand Up @@ -5,5 +5,6 @@
"types": ["node", "cypress", "@testing-library/cypress", "@4tw/cypress-drag-drop"],
"module": "ES2015",
"target": "ES2015",
"useDefineForClassFields": false,
}
}
64 changes: 64 additions & 0 deletions index.html
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Web site to manage keycloak" />
<title>Keycloak Administration Console</title>
<style>
body, #app {
height: 100%;
}

.container,
.container-fluid,
#load-container {
padding: 0;
margin: 0;
}

.container,
.container-fluid,
#load-container {
width: 100vw;
}

.keycloak__loading-container {
height: 100vh;
width: 100%;
background-color: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin: 0;
}

#loading-text {
z-index: 1000;
font-size: 20px;
font-weight: 600;
padding-top: 32px;
}
</style>
</head>
<body>
<div id="app">
<div class="container container-fluid" id="load-container">
<div class="keycloak__loading-container">
<span class="pf-c-spinner pf-m-xl" role="progressbar" aria-valuetext="Loading...">
<span class="pf-c-spinner__clipper"></span>
<span class="pf-c-spinner__lead-ball"></span>
<span class="pf-c-spinner__tail-ball"></span>
</span>
<div>
<p id="loading-text">Loading the admin console</p>
</div>
</div>
</div>
</div>

<noscript>You need to enable JavaScript to run this app.</noscript>
<script type="module" src="/src/main.tsx"></script> </body>
</html>
10 changes: 5 additions & 5 deletions keycloak-theme/pom.xml
Expand Up @@ -166,7 +166,7 @@
<outputDirectory>target/classes/theme/keycloak.v2/admin/resources</outputDirectory>
<resources>
<resource>
<directory>../build</directory>
<directory>../dist</directory>
</resource>
</resources>
</configuration>
Expand Down Expand Up @@ -204,18 +204,17 @@
<regex>false</regex>
<replacements>
<replacement>
<token>src="/</token>
<token>src="</token>
<value>src="${resourceUrl}/</value>
</replacement>
<replacement>
<token>href="/</token>
<token>href="</token>
<value>href="${resourceUrl}/</value>
</replacement>
<replacement>
<token><![CDATA[<body style="height: 100%;">]]></token>
<token><![CDATA[</body>]]></token>
<value xml:space="preserve">
<![CDATA[
<body style="height: 100%;">
<script id="environment" type="application/json">
{
"loginRealm": "${loginRealm!"master"}",
Expand All @@ -229,6 +228,7 @@
"isRunningAsTheme": true
}
</script>
</body>
]]>
</value>
</replacement>
Expand Down

0 comments on commit 5fa63d9

Please sign in to comment.