2
Introducing:
Let’s go to a practical example, so that it is simple to understand...
I want to use the framework Bulma in my project, so I run the following command:
$ npm install --save-dev bulma
Tchanram! Now I can find both the file Bulma.css complete in node_modules\bulma\css\bulma.css
as it is also possible to find the scss files in node_modules\bulma\sass\*
, hence the following question
Problem:
If I want to use the file Bulma.css complete, I should reference in my html the path to this file there in the directory node_modules
? I mean, insert into my <head>
the line: <link rel="stylesheet" href="node_modules\bulma\css\bulma.css">
?
Theoretically it makes sense, after all whoever cloned the project would have to run the $npm install
, and then I would have the dependency exactly in this way, but what if I want to build this project? I would have to necessarily use a task Runner (Gulp) to move a copy of that file into my project?
Finally, the most correct way of making use of these dependencies left me a little confused, taking into account these needs, which is the best practice to adopt?
P.S.: I already make use of Gulp in the project
If I chose the CDN alternative, wouldn’t I need to install the framework as the right dependency? It only makes sense to install as a dependency if I would use the files
scss
to be included in my styles as necessary ... I am correct?– Vinicius Colares
@Viniciuscolares exact. If you don’t need to modify them and you don’t need to work offline then CDN seems to me the simplest.
– Sergio
@If the advisable is to copy the sources into an internal structure, what is the advantage of using NPM to simply download the packages? If I go to download the packages individually I can do it directly through Github or download the Cdns Bundle, which will even prevent me from downloading several unnecessary sources and dependencies that I don’t necessarily use. In this regard I’m not seeing real application to download libraries via npm. Doing a parallel, I thought npm would create an autoload just like php’s Composer does.
– Paulo Lima