Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
How to global import a stylus file in vite

Now I'm try use vite to create a vue app. But have trouble to global import a stylus file in vite.config.js.

I try the code from vite docs.

export default defineConfig({
  css: {
    preprocessorOptions: {
      styl: {
        additionalData: `@import "./src/assets/styles/common.styl"`
      }
    }
  }
})

But it's completely not work.

I got a solution to set global style from github.

export default defineConfig({
  css: {
    preprocessorOptions: {
      stylus: {
        globals: {
          '$highlight-color': 'red'
        }
      }
    }
  }
})

It's works fine, But how to import a styl file globaly? I tried to add 'additionalData' to the workable config. However I got bunch of errors: 'failed to locate file'. It seems like try to import the file in every .vue file, but has trouble to locate the file.

  css: {
    preprocessorOptions: {
      stylus: {
        additionalData: `@import "./src/assets/styles/common.styl";`,
        globals: {
          '$color-g1': '#F3F4FC',
          '$color-white': '#FFFFFF',
        }
      }
    }
  }

Have any idea about this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda