1

I am using Vue Design System in order reuse components and styles in multiple Vue applications.

I'm trying to include a global CSS file in the DS export, but I can not get this to show in the app. Any tips ?

So far i have tried this which does not seem to load the required file.

// Install the above defined components
const System = {
  install(Vue) {
    require("./styles/global.scss") 

    components.forEach(component => Vue.component(component.name, component))
  },
}
export default System

which will be used as :

import DesignSystem from "@/system"
Vue.use(DesignSystem)

I can not find any guidelines in the Vue docs about loading CSS with a plugin.

1 Answer 1

3

Since Vue plugin is essentially set of components, you can bundle it's CSS like you would do with any other component. Just add it to root of your plugin component:

<style lang="scss">
@import "./styles/global.scss";
</style>
Sign up to request clarification or add additional context in comments.

2 Comments

Oh, that makes sense. But what do you mean by "root of my plugin component" ? I only have a number of small atomic presentational components, there is no root one.
You can import css everywhere if you are not sure about usage, webpack will make sure that it is loaded only once

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.