W
W
WeReng2016-04-17 11:07:51
npm
WeReng, 2016-04-17 11:07:51

How to correctly include styles of a module installed via npm?

Hello! Please clarify. I am creating my own WordPress template. I install the package via npm, it contains css or scss styles that I need to rewrite for myself. If I connect them to WP from the node_modules folder and edit css or scss in the node_modules folder, I think that when I update, all my changes will fly off. Is it really more correct to override styles in style.css, and if there are a lot of them? How to be in this situation? I just recently started using npm and gulp, I want to figure it out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2016-04-17
@WeReng

When working with modules that contain scss/less/styl styles, it is desirable to use them.
That is, somewhere we create a vendor.sass file, and in it we import the necessary styles from the installed packages.
If you write without using preprocessors, then you can configure gulp to copy / merge the necessary vendor styles from the node_modules folder into your folder.
In order to override vendor styles, you just need to have a folder in which to put files with vendor names, and make your own overrides for each vendor. Then it's just a matter of putting them together with gulp.
Edit vendor files categorically should not be. If you really need it, you can fork the project and make changes in your fork.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question