2

I am creating a component library where I do not want to have global CSS. Therefore, every component is scoped.

When running the production build via vue-cli-service build --target lib --name sc components/index.js, everything is compiled into sc.css and dist/css/1.392e001d.css.

If possible, I want to keep the css and/or scss combined with the vue file or js.

The reason I want to do this is to enable users of the library to import a singular component from the library. The users could then use the component anywhere without having to import/include a css file.

If this is not possible, is there a way to accomplish the desired functionality?

1 Answer 1

3

From the Vue CLI docs for css.extract:

When building as a library, you can also set this to false to avoid your users having to import the CSS themselves.

// vue.config.js
module.exports = {
  css: {
    extract: false
  }
}
Sign up to request clarification or add additional context in comments.

Comments

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.