Table of Contents

When compiling TypeScript, like for JavaScript, you have to know wether you are
going to develop in an application or a library. The good news is that Crafty
makes it a breeze to switch from one to the other.

Compiling TypeScript for a webapp ( Webpack / rollup.js )

When developing for a webapp, you wish for all files to be packed into the
smallest number of files, because the number of requests that a final
application will make are directly related to the performance of that
application.

Webpack and rollup.js do a great job at optimizing your bundles into the
smallest possible package. For this use case, we are going to use Webpack, but
they are interchangeable in this example.

Installing the preset with Gulp

In your crafty.config.js file, you must add the following presets and create a
bundle.

You can see that the bundle we created contains a glob as the source, this means
that all source files will be compiled separately, and the dependencies between
the files won’t be resolved (like Webpack or rollup.js would do).