Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Importing tokens from npm in Tailwind CSS config

I'm checking out the Theme Configuration in Tailwind CSS. It looks really powerful, but I'm having trouble using my design tokens within the config.

I have my tokens distributed via npm, but don't know how I can include them in my tailwind.config.js. Is there any way to include them like this? Should I use a different approach?

// What I'm trying to achieve
import DesignTokens from "@my-design-system/tokens";

module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
    colors: {
      blue: DesignTokens.COLOR_BLUE_700,
    },
  },
  plugins: [],
};

Error I get

SyntaxError: Cannot use import statement outside a module

Any info will be greatly appreciated.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As stated in the comments, using the import is mixing module formats.

I got it working with the following configuration.

// I have tokens available in many different formats thanks to Style Dictionary. Here we use JSON.
const DesignTokens = require("@my-design-system/tokens.json");

module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
    colors: {
      blue: {
        700: DesignTokens["color-blue-700"],
      },
    },
  },
  plugins: [],
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda