> For the complete documentation index, see [llms.txt](https://yamoo9.gitbook.io/webpack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yamoo9.gitbook.io/webpack/react/create-your-own-react-app/webpack-initialization.md).

# Webpack 초기 구성

## 1. NPM 초기화

`npm` 초기화(initialization) 명령을 사용해 프로젝트를 초기 구성합니다. (`package.json` 생성)

{% tabs %}
{% tab title="NPM 초기화 명령" %}

```bash
npm init -y
```

{% endtab %}

{% tab title="package.json" %}

```javascript
{
  "name": "euid-react-app",
  "version": "1.0.0",
  "description": "E.UID React App",
  "private": true,
  "scripts": {
    "start": "webpack"
  }
}
```

{% endtab %}
{% endtabs %}

![](/files/-MTuPnPgBFe00v2EWi0U)

## 2. Webpack 설치 & 구성

[webpack](https://www.npmjs.com/package/webpack), [webpack-cli](https://www.npmjs.com/package/webpack-cli) 패키지를 설치한 후, `webpack.config.js` 파일을 만들어 구성합니다.

{% tabs %}
{% tab title="패키지 설치" %}

```bash
npm i webpack webpack-cli -D
```

{% endtab %}

{% tab title="webpack.config.js" %}

```javascript
const path = require('path')
const getAbsolutePath = (pathDir) => path.resolve(__dirname, pathDir)

module.exports = (_env, argv) => {
  const isProd = argv.mode === 'production'
  const isDev = !isProd

  return {
    entry: {
      main: './src/index.js',
    },
    output: {
      path: getAbsolutePath('dist'),
      filename: 'assets/js/[name].[contenthash:8].js',
      publicPath: '/',
    },
    mode: 'development',
    devtool: isDev && 'cheap-module-source-map',
  }
}
```

{% endtab %}
{% endtabs %}

![](/files/-MTuTcWcDOu0SqkLD1Y3)

## 3. React, ReactDOM 설치

[react](https://www.npmjs.com/package/react), [react-dom](https://www.npmjs.com/package/react-dom) 패키지를 프로젝트에 설치합니다.

{% tabs %}
{% tab title="패키지 설치" %}

```bash
npm i react react-dom
```

{% endtab %}
{% endtabs %}

## 4. 엔트리 파일 생성

엔트리 파일을 만든 후, React, ReactDOM 모듈을 불러와 간단한 React 코드를 작성합니다.

{% tabs %}
{% tab title="src/index.js" %}

```javascript
import React from 'react';
import ReactDOM from 'react-dom';

// React 요소
const app = React.createElement(
  'div', 
  { className: 'app' }, 
  'React App 매뉴얼 구성'
);

// DOM 노드
const rootNode = document.getElementById('root');

// DOM 노드에 React 요소 렌더링
ReactDOM.render(app, rootNode);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://yamoo9.gitbook.io/webpack/react/create-your-own-react-app/webpack-initialization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
