spacecodeur
spacecodeur

Reputation: 2406

Symfony 4 and webpack encore, looking for good practice when adding a CSS third library

I'm on a Symfony 4 new project.

Via yarn, I installed (by example) the CSS library animate.css

yarn install animate.css

From the webpack.config.js file, I added the animate.css file like that :

.addStyleEntry('animate', './node_modules/animate.css/animate.css')

My question is : is it a good way to add a CSS library like that ? I'm not sure if use directly the node_module path is a good practice..

Is there a better way ?

Upvotes: 0

Views: 312

Answers (1)

Avior
Avior

Reputation: 511

Normally you inject it directly in the .js file you are using

ex:

require('animate.css/animate.css')

or something in this way depending on your js superset if you have one so it will generate a .css file with your .js

an example is this: on my first line of my typescript file I call this import ./style.css
after that Encore will generate me a nwe .css file that i can use in my template using {{ encore_entry_link_tags('entry') }}

Upvotes: 1

Related Questions