Paul
Paul

Reputation: 8172

npm: How to create debug and production builds with the correct dependencies?

I am building a single page app which uses typescript and a few other dependencies (jquery, immutable, lodash, react, ...). The different resulting modules are included with requirejs.

I want to create both debug and production builds, where the debug builds should include the debug builds of the dependencies (i.e. non-minified, with debug checks (e.g. for React)) and the production builds should include the minified production builds of the dependencies.

How can I do this with npm (no grunt, gulp, etc. please)?

Upvotes: 3

Views: 3781

Answers (1)

raidendev
raidendev

Reputation: 2799

If you don't want to use any external build tool/task runner based on plugins (such as grunt or gulp) you could do everything just using your modules' CLI and npm scripts. Note that this way requires more knowledge about your OS environment such as pipes and of course you should be very familiar with node itself because you may need to write some wrappers for build tasks.

NPM scripts supports various hooks that can be used to separate development and production processes. For example, preinstall could be used to build a development release and prepublish for production and deploy.

There is pretty useful article by Keith Cirkel "How to Use npm as a Build Tool". Check it out.

Upvotes: 1

Related Questions