Search code examples
javascriptnpmwebpackgulp

Npm, Dev dependecy or dependecy, when packing everything into one script using webpack etc?


When for example with webpack we pack everything into a single js file, it already imports dependencies to that file. in that case, do we need any dependency in package.json, or they can be all --save-dev?

Please consider that I only talk about front end development and implementation.

Cheers


Solution

  • It depends on how your app gets deployed or distributed. Regular dependencies are what the app needs at runtime. Something is a dev dependency when it is only required in order to make changes to the app.

    If the webpack build has to run before the app can be used (e.g. in a continuous integration environment, where the app is built as part of the test & deploy process), then anything required at build time is a 'regular' dependency. In this case most of your packages will be regular dependencies.

    If you are building the app once and the built assets are what gets distributed/deployed -- so the build does not have to be done again before the app can be used -- then anything required at build time is a 'dev' dependency, because someone using your code should not have to build again unless they are making changes to the app. In this case most of your dependencies will be 'dev' dependencies.