Is node-sass a dev or a production dependency on React projects?
Asked Answered
G

2

45

In variaous React documentation I see it being added as a prod dependency but I'm not understanding why. Shouldn't it be a devDependecy since SASS only gets compiled during development and when pushed to prod you are actually pushing the compiled CSS files?

Gorgonzola answered 10/3, 2019 at 15:46 Comment(0)
T
29

Since it's required to do a production build, it should be in the production dependencies list imho.

In my experience, most of the time the project gets build afresh for production, so needs all the packages required to build from scratch.

A dev dependency might something like webpack-dev-server which isn't needed for a prod build, but clearly is used in development (assuming one is using it).

Thoer answered 10/3, 2019 at 23:53 Comment(3)
That's one way to look at it, but this doesn't mean we are sharing the same beliefs. From my point of view, it's a dev dependency as it will help transpile the SASS to CSS - not required for running production code, as it is axios.Scudo
I do not necessary agree as on the official Node website Babel is considered a development dependency: nodejs.dev/en/learn/npm-dependencies-and-devdependencies . Thank You and @Gorgonzola anyway.Elburt
Sass is not used in the browser. It's a build tool. It compiless .scss and .sass files to css.Hydrargyrum
E
7

On the official NPM site of sass (linked also here: " Sould SASS be installed as a 'dependency' or as a 'devDependency? ") it is suggested to install it as development dependency (aside from installing it globally) so I believe that's the way to go.

Also, as it's suggested on official Node website, Babel should be installed as a development dependency and that's the package that, I believe, may be required to create a production build. Considering that I think that all packages that are not required during runtime of an application should be installed as development dependencies.

Elburt answered 8/9, 2022 at 22:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.