Ben Carey
Ben Carey

Reputation: 16948

Bundle styles in Vue Plugin without Component

My Question

Before reading further, by 'without component', I mean that my plugin does not require a component as there is no template, it is simply a custom Vue Directive that serves as a wrapper to a class. However, that does not mean that I am not willing to use a component in order to include the necessary styles if this cannot be avoided...

Consider the following plugin (proposed file structure):

src
│   index.js
│   SomeClass.js    
│
└───sass // (not sure about this)
    │   core.scss

My question, quite simply, is how do I include the core.scss file when the Vue plugin is installed? Or, what would be a better file structure, thus way to include the styles required for the plugin?

Ideally, I would like to avoid using a template as there is no HTML inserted, my plugin simply adds styles to already defined elements in the DOM.

Upvotes: 2

Views: 502

Answers (1)

Ben Carey
Ben Carey

Reputation: 16948

For anyone stumbling upon this, the solution was extremely easy... I simply placed the following at the top of my index.js:

import './sass/_core.scss';

I wasn't aware that you could import CSS/SASS files directly into Javascript files...

Upvotes: 2

Related Questions