Skip to content

Bundled AdminJS does not include style.css items from Themes #11

@mikypilota

Description

@mikypilota

If a theme is defined as per this piece of documentation

import path from 'path';
import * as url from 'url';

const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

// ...

const myCustomTheme = {
  id: 'my-custom-theme',
  name: 'My Custom Theme',
  overrides: {
    colors: {
      primary100: 'teal',
    },
  },
  bundlePath: `${path.join(__dirname, `../themes/my-custom-theme`)}/theme.bundle.js`,
  stylePath: `${path.join(__dirname, `../themes/my-custom-theme`)}/style.css`,
}

// *

And then said theme is added to the AdminJS instance

const admin = new AdminJS({
  defaultTheme: myCustomTheme.id,
  availableThemes: [myCustomTheme],
})

When everything is bundled with

(async () => {
  await bundle({
    componentLoader,
    destinationDir: "public",
  });
})();

The CSS files will not be carried over.

You can reproduce it not only with a custom theme but also using any default theme from @adminjs/themes, for instance:

import {dark} from "@adminjs/themes";

const admin = new AdminJS({
  defaultTheme: dark.id,
  availableThemes: [dark],
})

And you will see that when running in development the colors will show correctly, whilst when building and running in production the font colors of the navbar will be off (black over black in the above case) as the style.css from the dark theme is not actually bundled and served.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions