2

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
  • index.js installs the Vue plugin and defines a custom directive that calls certain methods on the SomeClass class
  • SomeClass.js provides all required functionality
  • sass/core.scss provides any necessary styles required for the plugin

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.

1 Answer 1

2

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...

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.