SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.15k stars 659 forks source link

Add babel plugins for custom components #1304

Open trangvu9 opened 1 year ago

trangvu9 commented 1 year ago

Hi there,

I'm building a custom dashboard that uses tailwind css.

I got error that said something about @babel/plugin-proposal-decorators plugin is required.

I fiddled around with the bundler.babelConfig, but it seems it screwed up other things. I tried to copy the babelrc here and add adapt the plugin to it, still no luck. Any clue?

const admin = new AdminJS({
    bundler: {
      babelConfig: {
        "presets": [
          "@babel/preset-react",
          ["@babel/preset-env", {
            "targets": {
              "node": "16"
            }
          }],
          "@babel/preset-typescript"
        ],
        "plugins": [
          "babel-plugin-styled-components",
          ['@babel/plugin-proposal-decorators', { legacy: true }],
        ],
      }
    },
    dashboard:{
      component: AdminJS.bundle("./customPages/src/index"),
    },

Current error:

SyntaxError: .../customPages/src/styles/index.scss: Leading decorators must be attached to a class declaration. (1:10)

> 1 | @tailwind base;

Thanks

dziraf commented 1 year ago

Never had to use Tailwind or import any css files but you might also need a scss transpiler/tailwind plugin for babel