# Installation और basic setup — Webpack

Source: https://www.geekswithgeeks.com/hi/webpack/webpack-02

> अपने project में Webpack set up करें और अपना पहला bundle बनाएँ।

## Installation के बुनियाद

Webpack को Node.js की जरूरत है। webpack और webpack-cli को dev dependencies के रूप में install करें। webpack-cli tool bundling के लिए command-line interface provide करता है। Basic setup को entry points, output locations और loaders को define करने वाली configuration file की जरूरत है।

## Install और configure करें

webpack.config.js को entry और output configuration के साथ बनाएँ।

```bash
npm install --save-dev webpack webpack-cli
npm run build
```

Output:

```
asset main.js 2.5 KiB [compared for emit] (name: main)
webpack 5.89.0 compiled successfully
```

## Basic webpack.config.js

Entry point और output bundle location को configure करें।

```javascript
module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: __dirname + '/dist'
  }
};
```

Output:

```
Configuration accepts: entry, output, mode, module, plugins, devServer
```

## Mode optimization को प्रभावित करता है

Mode को 'development' पर readable output और fast builds के लिए set करें, या 'production' को optimized, minified output के लिए। Mode automatically optimization settings को configure करता है।
