webpack vs gulp vs grunt vs parcel
ビルドツール
webpackgulpgruntparcel類似パッケージ:
ビルドツール

ビルドツールは、フロントエンド開発において、コードのコンパイル、圧縮、最適化などのプロセスを自動化するためのツールです。これにより、開発者は手動での作業を減らし、効率的にプロジェクトを管理することができます。これらのツールは、特に大規模なアプリケーションや複雑なプロジェクトにおいて、開発の生産性を向上させる役割を果たします。

npmのダウンロードトレンド
3 年
GitHub Starsランキング
統計詳細
パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
webpack34,092,70065,8295.69 MB2088時間前MIT
gulp1,663,34033,03711.2 kB347ヶ月前MIT
grunt826,80612,26968.3 kB1643年前MIT
parcel248,23344,02743.9 kB57612日前MIT
機能比較: webpack vs gulp vs grunt vs parcel

設定の柔軟性

  • webpack:

    Webpackは複雑な設定が必要ですが、その分、強力な機能を提供します。特に、モジュールの依存関係を管理する能力が高く、大規模なアプリケーションに適しています。

  • gulp:

    GulpはJavaScriptコードを使用してタスクを定義するため、設定がより柔軟であり、プラグインを簡単に追加できます。可読性が高く、直感的にタスクを管理できます。

  • grunt:

    Gruntは設定ファイルを使用してタスクを定義します。設定が明示的であるため、タスクの流れを理解しやすいですが、設定が多くなると複雑になることがあります。

  • parcel:

    Parcelは設定不要で、すぐにプロジェクトを開始できます。開発者は設定に時間をかけることなく、すぐに開発に集中できます。

パフォーマンス

  • webpack:

    Webpackはコード分割や遅延読み込みをサポートしており、大規模なアプリケーションのパフォーマンスを最適化できます。特に、初期読み込み時間を短縮するのに役立ちます。

  • gulp:

    Gulpはストリーミング処理を行うため、タスクの実行が非常に高速です。ファイルの変更を監視し、変更があった場合のみ再実行するため、効率的です。

  • grunt:

    Gruntはタスクを一つずつ実行するため、タスクの数が多いと実行時間が長くなることがあります。特に大規模なプロジェクトでは、パフォーマンスが問題になることがあります。

  • parcel:

    Parcelは開発中にホットリロードをサポートしており、変更を即座に反映できます。これにより、開発者は迅速にフィードバックを得ることができます。

学習曲線

  • webpack:

    Webpackは強力ですが、設定が複雑であるため、学習曲線が急です。特に初めて使う場合は、ドキュメントをしっかりと読む必要があります。

  • gulp:

    GulpはJavaScriptでタスクを定義するため、JavaScriptに慣れている開発者には比較的学びやすいです。直感的なAPIが特徴です。

  • grunt:

    Gruntは設定ファイルを理解する必要があり、初学者には少し難しいかもしれません。しかし、設定をマスターすれば、強力なタスク管理が可能です。

  • parcel:

    Parcelは設定不要で、すぐに使い始められるため、初心者にとって非常に学びやすいです。

拡張性

  • webpack:

    Webpackは非常に多くのプラグインとローダーがあり、機能を拡張するための選択肢が豊富です。特に、複雑なアプリケーションにおいては、その拡張性が大きな利点となります。

  • gulp:

    Gulpはプラグインの追加が容易で、タスクを自由に組み合わせることができます。これにより、プロジェクトのニーズに応じた柔軟な構成が可能です。

  • grunt:

    Gruntは多くのプラグインが存在し、必要に応じて機能を追加できますが、設定が複雑になることがあります。

  • parcel:

    Parcelはプラグインのサポートが限られていますが、設定不要で使いやすいため、迅速な開発には適しています。

コミュニティとサポート

  • webpack:

    Webpackは非常に人気があり、広範なドキュメントとコミュニティサポートがあります。多くのリソースが利用可能で、問題解決が容易です。

  • gulp:

    Gulpも人気があり、活発なコミュニティが存在します。多くのリソースやプラグインが利用可能です。

  • grunt:

    Gruntは古くからあるツールであり、豊富なドキュメントとコミュニティサポートがあります。

  • parcel:

    Parcelは比較的新しいツールですが、急速に成長しており、コミュニティも活発です。

選び方: webpack vs gulp vs grunt vs parcel
  • webpack:

    Webpackはモジュールバンドラーとして非常に強力で、複雑なアプリケーションに適しています。コード分割や遅延読み込みなどの高度な機能を活用したい場合に選ぶと良いでしょう。

  • gulp:

    Gulpはストリーミングビルドシステムを使用しており、タスクの実行が高速です。コードの可読性を重視し、プラグインを活用して柔軟にカスタマイズしたい場合に適しています。

  • grunt:

    Gruntは設定ファイルを使用してタスクを定義するため、設定が明示的であることを重視するプロジェクトに適しています。設定が多くなると複雑になる可能性があるため、タスクの管理がしやすい場合に選ぶと良いでしょう。

  • parcel:

    Parcelは設定不要で、開発者がすぐにプロジェクトを開始できる点が魅力です。特に小規模なプロジェクトやプロトタイピングに適しており、迅速な開発を求める場合に選ぶと良いでしょう。

webpack のREADME


npm

node builds1 dependency-review coverage pkg.pr.new PR's welcome compatibility-score downloads install-size backers sponsors contributors discussions discord LFX Health Score

webpack

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Table of Contents

Install

Install with npm:

npm install --save-dev webpack

Install with yarn:

yarn add webpack --dev

Introduction

Webpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

TL;DR

  • Bundles ES Modules, CommonJS, and AMD modules (even combined).
  • Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
  • Dependencies are resolved during compilation, reducing the runtime size.
  • Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
  • Highly modular plugin system to do whatever else your application requires.

Learn about webpack through videos!

Get Started

Check out webpack's quick Get Started guide and the other guides.

Browser Compatibility

Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported). Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.

Concepts

Plugins

Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack very flexible.

NameStatusInstall SizeDescription
mini-css-extract-pluginmini-css-npmmini-css-sizeExtracts CSS into separate files. It creates a CSS file per JS file which contains CSS.
compression-webpack-plugincompression-npmcompression-sizePrepares compressed versions of assets to serve them with Content-Encoding
html-bundler-webpack-pluginbundler-npmbundler-sizeRenders a template (EJS, Handlebars, Pug) with referenced source asset files into HTML.
html-webpack-pluginhtml-plugin-npmhtml-plugin-sizeSimplifies creation of HTML files (index.html) to serve your bundles
pug-pluginpug-plugin-npmpug-plugin-sizeRenders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug.

Loaders

Webpack enables the use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.

Loaders are activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration.

JSON

NameStatusInstall SizeDescription
cson-npmcson-sizeLoads and transpiles a CSON file

Transpiling

NameStatusInstall SizeDescription
babel-npmbabel-sizeLoads ES2015+ code and transpiles to ES5 using Babel
type-npmtype-sizeLoads TypeScript like JavaScript
coffee-npmcoffee-sizeLoads CoffeeScript like JavaScript

Templating

NameStatusInstall SizeDescription
html-npmhtml-sizeExports HTML as string, requires references to static resources
pug-npmpug-sizeLoads Pug templates and returns a function
pug3-npmpug3-sizeCompiles Pug to a function or HTML string, useful for use with Vue, React, Angular
md-npmmd-sizeCompiles Markdown to HTML
posthtml-npmposthtml-sizeLoads and transforms a HTML file using PostHTML
hbs-npmhbs-sizeCompiles Handlebars to HTML

Styling

NameStatusInstall SizeDescription
<style>style-npmstyle-sizeAdd exports of a module as style to DOM
css-npmcss-sizeLoads CSS file with resolved imports and returns CSS code
less-npmless-sizeLoads and compiles a LESS file
sass-npmsass-sizeLoads and compiles a Sass/SCSS file
stylus-npmstylus-sizeLoads and compiles a Stylus file
postcss-npmpostcss-sizeLoads and transforms a CSS/SSS file using PostCSS

Frameworks

NameStatusInstall SizeDescription
vue-npmvue-sizeLoads and compiles Vue Components
polymer-npmpolymer-sizeProcess HTML & CSS with preprocessor of choice and require() Web Components like first-class modules
angular-npmangular-sizeLoads and compiles Angular 2 Components
riot-npmriot-sizeRiot official webpack loader
svelte-npmsvelte-sizeOfficial Svelte loader

Performance

Webpack uses async I/O and has multiple caching levels. This makes webpack fast and incredibly fast on incremental compilations.

Module Formats

Webpack supports ES2015+, CommonJS and AMD modules out of the box. It performs clever static analysis on the AST of your code. It even has an evaluation engine to evaluate simple expressions. This allows you to support most existing libraries out of the box.

Code Splitting

Webpack allows you to split your codebase into multiple chunks. Chunks are loaded asynchronously at runtime. This reduces the initial loading time.

Optimizations

Webpack can do many optimizations to reduce the output size of your JavaScript by deduplicating frequently used modules, minifying, and giving you full control of what is loaded initially and what is loaded at runtime through code splitting. It can also make your code chunks cache friendly by using hashes.

Developer Tools

If you're working on webpack itself, or building advanced plugins or integrations, the tools below can help you explore internal mechanics, debug plugin life-cycles, and build custom tooling.

Instrumentation

NameStatusDescription
tapable-tracertapable-tracer-npmTraces tapable hook execution in real-time and collects structured stack frames. Can export to UML for generating visualizations.

Contributing

We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone. We have a vibrant ecosystem that spans beyond this single repo. We welcome you to check out any of the repositories in our organization or webpack-contrib organization which houses all of our loaders and plugins.

Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:

To get started have a look at our documentation on contributing.

Creating your own plugins and loaders

If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the x-loader, x-webpack-plugin naming convention.

Support

We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the easiest entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!

If you're just getting started, take a look at our new docs and concepts page. This has a high level overview that is great for beginners!!

If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.

Current project members

For information about the governance of the webpack project, see GOVERNANCE.md.

TSC (Technical Steering Committee)

Maintenance

This webpack repository is maintained by the Core Working Group.

Sponsoring

Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

This is how we use the donations:

  • Allow the core team to work on webpack
  • Thank contributors if they invested a large amount of time in contributing
  • Support projects in the ecosystem that are of great value for users
  • Support projects that are voted most (work in progress)
  • Infrastructure cost
  • Fees for money handling

Premium Partners

Other Backers and Sponsors

Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.

Gold Sponsors

Become a gold sponsor and get your logo on our README on GitHub with a link to your site.

Silver Sponsors

Become a silver sponsor and get your logo on our README on GitHub with a link to your site.

Bronze Sponsors

Become a bronze sponsor and get your logo on our README on GitHub with a link to your site.

Backers

Become a backer and get your image on our README on GitHub with a link to your site.

Special Thanks to

(In chronological order)

  • @google for Google Web Toolkit (GWT), which aims to compile Java to JavaScript. It features a similar Code Splitting as webpack.
  • @medikoo for modules-webmake, which is a similar project. webpack was born because of the desire for code splitting for modules such as Webmake. Interestingly, the Code Splitting issue is still open (thanks also to @Phoscur for the discussion).
  • @substack for browserify, which is a similar project and source for many ideas.
  • @jrburke for require.js, which is a similar project and source for many ideas.
  • @defunctzombie for the browser-field spec, which makes modules available for node.js, browserify and webpack.
  • @sokra for creating webpack.
  • Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction.
  • All past and current webpack maintainers and collaborators.
  • Everyone who has written a loader for webpack. You are the ecosystem...
  • Everyone not mentioned here but that has also influenced webpack.