Should sass be installed as a 'dependency' or as a 'devDependency'?
In the npm page says: " You can also add it to your project using npm install --save-dev sass."
But in the Install Sass page there is no information about this topic.
I have it like this and it works:
"devDependencies": {
"@parcel/transformer-sass": "^2.3.2",
"parcel": "^2.3.2"
},
"dependencies": {
"normalize.css": "^8.0.1",
"sass": "^1.49.8"
}
But I wonder whether I should better have it as a devDependency.
I highly advise against installing npm packages like sass
as a global dependency, this is particular important when you work collaboratively with others. The packages required for a project to run out of the box should be installed within the package itself. This ensures everything is contained within, and the project is capable of running standalone by a participant cloning the repo and running npm i
.
As you mentioned, the official documentation for sass
recommends installing it to a project via running npm install --save-dev sass
. It should be noted that sass
is a preprocessor which compiles .sass
and .scss
files to .css
. It is therefore not required to run at production because when we compile our production build (such as with webpack), the associated .css
files would have been generated. Thus, it is safe to download it as a dev dependency because we only need it during development.