Skip to content

demo webpack setup that demonstrates code elemination

Notifications You must be signed in to change notification settings

thomn/demo-eleminatecode

Repository files navigation

demo-eleminatecode

This is a simple demo project that shows how dead code elemination and conditional compilation works in a webpack setup.

This repository holds the code examples that are used in the Blog post Conditional compilation and dead code elimination with webpack on thomann.io.

Clone this repository, and install the dependencies (assuming you have already installed node and npm):

$ git clone [email protected]:thomn/demo-eleminatecode.git && npm i

Run the following command to create a dev build:

$ npm run dev

A development build has been created and can be viewed at build/index.js. The dev build is very cluttered and verbose, it is not minified, retains all comments and a huge amount of code that is not actually used at all.

$ npm run prod

Under build/index.js now the production build can be found. The output is completely minified and a lot smaller as a huge portion of the original code has been removed. The webpack setup with UglifyJS is able to determine which part of the code is needed and which part of the code can be savely thrown away.

About

demo webpack setup that demonstrates code elemination

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published