Webpack uses loaders to simplify conversion of file formats:
Loaders are transformations that are applied on the source code of a module. They allow you to pre-process files as you import or “load” them. Thus, loaders are kind of like “tasks” in other build tools, and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript, or inline images as data URLs. Loaders even allow you to do things like import CSS files directly from your JavaScript modules!
Gulp is stronger at several things that complement webpackWebpack. For example:
- Static File Handling
Gulp can handle static assets better than Webpack. The Copy Webpack Plugincopy-webpack- plugin can also copy files from your source to your build folder but when it comes to watching file deletion or changes like overriding an image, gulp.watch is a safer bet.
- Server Environment
Webpack also comes with a local server environment via Webpack Dev Server but using BrowserSync has some features you might not want to miss:
CSS/HTML/image injection for non-app projects Multiple device testing out of the box Includes an admin panel for more control Bandwidth throttling for speed and loading tests
- Compilation Time
As seen in this post on GitHub, SASS gets processed by
node-sassmuch quicker than by Webpack's combination ofsass-loader,css-loaderandextract-text-webpack-plugin.
- Convenience
In Webpack, you have to import your CSS and SVG files for instance into JavaScript to process them which can be quite tricky and confusing sometimes. With Gulp, you don't need to adjust your workflow.
References