* docs: migrate ui docs to docs universe * created yarn workspace * added eslint and tsconfig configurations * fix eslint configurations * fixed eslint configurations * shared tailwind configurations * added shared ui package * added more shared components * migrating more components * made details components shared * move InlineCode component * moved InputText * moved Loading component * Moved Modal component * moved Select components * Moved Tooltip component * moved Search components * moved ColorMode provider * Moved Notification components and providers * used icons package * use UI colors in api-reference * moved Navbar component * used Navbar and Search in UI docs * added Feedback to UI docs * general enhancements * fix color mode * added copy colors file from ui-preset * added features and enhancements to UI docs * move Sidebar component and provider * general fixes and preparations for deployment * update docusaurus version * adjusted versions * fix output directory * remove rootDirectory property * fix yarn.lock * moved code component * added vale for all docs MD and MDX * fix tests * fix vale error * fix deployment errors * change ignore commands * add output directory * fix docs test * general fixes * content fixes * fix announcement script * added changeset * fix vale checks * added nofilter option * fix vale error
4.1 KiB
description
| description |
|---|
| In this document, you'll learn about the different ways you can configure the admin dashboard for your custom use cases. |
Admin Custom Configuration
In this document, you'll learn about the different ways you can configure the admin dashboard for your custom use cases.
Admin CLI
Build Command Options
The build command in the admin CLI allows you to manually build the admin dashboard. If you intend to use it, you should typically add it to the package.json of the Medusa backend:
{
"scripts": {
// other scripts...
"build:admin": "medusa-admin build"
}
}
You can add the following option to the medusa-admin build command:
--deployment: a boolean value indicating that the build should be ready for deployment. When this option is added, options are not loaded frommedusa-config.jsanymore, and it means the admin will be built to be hosted on an external host. This also means that the backend URL is loaded from theMEDUSA_ADMIN_BACKEND_URLenvironment variable. For example,medusa-admin build --deployment.
Dev Command Options
The develop command in the admin CLI allows you to run the admin dashboard in development separately from the Medusa backend. If you intend to use it, you should typically add it to the package.json of the Medusa backend:
{
"scripts": {
// other scripts...
"dev:admin": "medusa-admin develop"
}
}
You can add the following options to the medusa-admin dev command:
--backendor-b: a string specifying the URL of the Medusa backend. By default, it's the value of the environment variableMEDUSA_ADMIN_BACKEND_URL. For example,medusa-admin dev --backend example.com.--portor-p: the port to run the admin on. By default, it's7001. For example,medusa-admin dev --port 8000.
Custom Environment Variables
If you want to set environment variables that you want to access in your admin dashboard's customizations (such as in widgets or UI routes), your environment variables must be prefixed with MEDUSA_ADMIN_. Otherwise, it won't be loaded within the admin.
For example:
MEDUSA_ADMIN_CUSTOM_API_KEY=123...
Custom Webpack Configurations
:::note
Plugins cannot include webpack customizations.
:::
The admin dashboard uses Webpack to define the necessary configurations for both the core admin plugin and your extensions. So, for example, everything works out of the box with Tailwind CSS, the admin dependencies, and more.
However, you may have some advanced case where you need to tweak the webpack configurations. For example, you want to support styling your extensions with CSS Modules.
For such use cases, you can extend the default webpack configurations defined in the admin plugin to add your custom configurations.
To do that, create the file src/admin/webpack.config.js that uses the withCustomWebpackConfig method imported from @medusajs/admin to export the extended configurations. The method accepts a callback function that must return an object of webpack configuration. The callback function accepts two parameters:
config: the first parameter is an object that holds the default webpack configuration. You should add your configurations to this object, then return it. Not returning the default configurations will lead to the application breaking.webpack: the second parameter is the webpack instance.
:::warning
This is an advanced feature and requires knowledge of configuring webpack. If configured wrongly, it may lead to the admin application breaking.
:::
For example:
import { withCustomWebpackConfig } from "@medusajs/admin"
export default withCustomWebpackConfig((config, webpack) => {
config.plugins.push(
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
API_URL:
JSON.stringify("https://api.medusa-commerce.com"),
},
})
)
return config
})