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

343
Vistas
Why css is not applied for a component of one app into another app in vue

Hi i have situation where css and scss is not applied of a component of 1 app into another app

I have 2 apps

  1. core
  2. plugins

i want to use the components of a core app into plugins app

here is how i'm doing

Core App

//main.js

import "bootstrap/dist/css/bootstrap.min.css";
const app1 = new Vue({
    render: h => h(App),
    ....
})

//core.component.vue

<template>
   .....
</template>
<script>
   export default{
       name:'CoreComponent',
       ....
    }
</script>
<styles lang="scss" scoped>
   $bgColor:red;   <--- these css are not applied when used in app 2
   ...             <--- these css are not applied when used in app 2
</styles>

Core provides component mappers for providing component when requested to plugins.

//core-component-mapper.js

export default{
  CoreComponent: require('path/CoreComponent.vue').default,
}

Below my plugins App setup

import "bootstrap/dist/css/bootstrap.min.css";
import CoreComponentMapper 'path/core-component-mapper.js'

const app2 = new Vue({
    render: h => h(App),
    components:{
      FirstCoreComp: CoreComponentMapper.CoreComponent,
    },
})

Note: please ignore any mistake in my demo code, code works perfectly in my setup except user defined css is not applied

Question: whichever css is defined on component of app 1 i,e core by me is not applied when used in App 2 i,e plugins

Note: i did not setup any webpack config i guess my both vue app is using default vue-loader config

Intresting thing is that bootstrap css works don't know why.(it is used in both the apps)

@MatJ as you asked in one of your comment i'm attaching screenshot (as per me css are not merged , but inline css are applied well)

enter image description here

enter image description here

Please help me thanks in advance!!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It looks like the css that are not being applied are inside a scoped block:

<style lang="scss" scoped>

and this is exactly how scoped css in vue are supposed to work.

If you wish to have a common shared style, just put the variables you need in a separate .css file and import it like you do with the bootstrap css.

over 4 years ago · Santiago Trujillo Denunciar

0

Here is an article explaining properly all the solutions that are available with Vue3 style tag.

Here, you could either:

  • remove scoped from your style tag (it's not styles btw)
  • inject some global CSS coming from another file higher in the app
  • use the new :global(.your-query-selector) selector.
over 4 years ago · Santiago Trujillo Denunciar
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