Upgrading the UI Customizer
The customizer helps extend the functionality of the UI by allowing you to add custom components to the UI. This guide will help you upgrade the customizer to the latest version.
Prerequisites​
- Node.js version 20 or above (which can be checked by running
node -v). - Docker
Steps​
Dependencies to remove​
- react-scripts
- node-sass
Dependencies to add​
- Add the following dependencies to the customizer folder
- npm
- pnpm
- Yarn
- Bun
npm install -D @babel/cli @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-plugin-cjs-esm-interop sass watch
pnpm add -D @babel/cli @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-plugin-cjs-esm-interop sass watch
yarn add --dev @babel/cli @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-plugin-cjs-esm-interop sass watch
bun add --dev @babel/cli @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-plugin-cjs-esm-interop sass watch
Update the package.json file​
- Add the following scripts to the package.json file
package.json
{
"scripts": {
"dist": "rm -rf dist && sass ./src/scss:./dist/css && babel src/ -d dist --copy-files && npm link",
"watch": "watch 'npm run dist ' ./src",
"css": "watch 'npm run css_dist ' ./src"
}
}
2. Add the babel configuration in the package.json
```json title="package.json"
{
"babel": {
"babel": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
],
"plugins": [
"@babel/plugin-transform-runtime",
[
"babel-plugin-cjs-esm-interop",
{
"format": "mjs"
}
]
]
},
}
}
- Add the package exports configuration
package.json
{
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"./dist/css/index.css": "./dist/css/index.css"
}
}
- Move react, and react-dom to peer dependencies. You can move the dependencies that exist in the ui to peer dependencies so as to prevent conflicts.
- npm
- pnpm
- Yarn
- Bun
npm install --save-peer react@18 react-dom@18 semantic-ui-react@3.0.0-beta.2 immutable
pnpm add --save-peer react@18 react-dom@18 semantic-ui-react@3.0.0-beta.2 immutable
yarn add --save-peer react@18 react-dom@18 semantic-ui-react@3.0.0-beta.2 immutable
bun add --save-peer react@18 react-dom@18 semantic-ui-react@3.0.0-beta.2 immutable
Update the Dockerfile​
- Update the Dockerfile to include the following commands
# Before
FROM node:12.22.12
# After
FROM node:22-slim
WORKDIR /tmp/work
COPY ./package.json .
RUN npm install
COPY src src
RUN npm run dist
Running the customizer​
To run the customizer, run the following command:
npm run watch
This will watch for changes in the src folder and compile the files to the dist folder.
Building the customizer​
To build the customizer, run the following command:
npm run dist