Hi Ecnerwal1234, here's some guidance.
Replace "mysite" with whatever you want, but make sure you update it in ALL locations found in my below sample code, it does matter.
- For Production, you will need to Build the react project. I assume you used the Admin Boilerplate, right? Then you should have a "build" command which executes "webpack --mode=production", you'll need to run that as part of your build pipeline
// package.json
{
"name": "mysite-web-admin",
"version": "1.0.0",
"description": "Your title administration project.",
"private": true,
"scripts": {
"start": "webpack serve --mode development",
"build": "webpack --mode=production"
},
"dependencies": {
"@kentico/xperience-admin-base": "31.0.0", // YOur Xperience Version
"@kentico/xperience-admin-components": "31.0.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@babel/core": "7.25.2",
"@babel/plugin-transform-runtime": "7.24.7",
"@babel/preset-env": "7.25.3",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@kentico/xperience-webpack-config": "29.4.1",
"@types/react": "18.0.33",
"@types/react-dom": "18.3.0",
"babel-loader": "9.1.3",
"webpack": "^5.101.3",
"webpack-cli": "5.1.4",
"webpack-dev-server": "^5.2.2"
},
"overrides": {
"react": "$react",
"react-dom": "$react",
"json-joy": ">= 11.19.0"
},
"browserslist": [
"> .2% and last 3 versions",
"not op_mini all",
"not IE 11"
]
}
// webpack.config.js
const webpackMerge = require("webpack-merge");
const baseWebpackConfig = require("@kentico/xperience-webpack-config");
module.exports = (opts, argv) => {
const baseConfig = (webpackConfigEnv, argv) => {
return baseWebpackConfig({
// Sets the organizationName and projectName
// The JS module is registered on the backend using these values
orgName: "mysite",
projectName: "web-admin",
webpackConfigEnv: webpackConfigEnv,
argv: argv,
});
};
const projectConfig = {
module: {
rules: [
{
test: /\.(js|ts)x?$/,
exclude: [/node_modules/],
loader: "babel-loader",
},
],
},
output: {
clean: true
},
// Webpack server configuration. Required when running the boilerplate in 'Proxy' mode.
devServer: {
port: 3070,
},
};
return webpackMerge.merge(projectConfig, baseConfig(opts, argv));
};
``` ```
You need to make sure to register your Client Module in a AdminModule class:
[assembly: RegisterModule(typeof(XperienceAdminModule))]
namespace Admin
{
public class XperienceAdminModule : AdminModule
{
public XperienceAdminModule() : base("XperienceAdminModule")
{
}
protected override void OnInit(ModuleInitParameters parameters)
{
base.OnInit();
// Makes the module accessible to the admin UI
RegisterClientModule("mysite", "web-admin");
}
}
}
In your .csproj file for your admin application, you also need to include this to tell it to include the compiled files. Special attention to line 9, 22-34 in the below
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<AdminOrgName>mysite</AdminOrgName> <!-- Should match prefix -->
</PropertyGroup>
<!-- Disable stupid Result conflict with HotChocolate -->
<PropertyGroup>
<HotChocolateImplicitUsings>disable</HotChocolateImplicitUsings>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="CMS.AssemblyDiscoverableAttribute" />
</ItemGroup>
<ItemGroup>
<AdminClientPath Include="Client\dist\**">
<ProjectName>web-admin</ProjectName>
</AdminClientPath>
</ItemGroup>
<ItemGroup>
<Compile Remove="Client\node_modules\**" />
<EmbeddedResource Remove="Client\node_modules\**" />
<None Remove="Client\node_modules\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="Client\" /> <!-- Where the admin react client is, for mine it was a folder at the root "Client" -->
</ItemGroup>
</Project>
Your admin page should of course also register the custom react:
[assembly: UIPage(typeof(ClassroomOrdersApplicationPage),
"order-handler",
typeof(CustomOrderHandlerTemplate),
"Order Handler",
"@mysite/web-admin/CustomOrderHandler",
0)]