# \[WEBPACK] 2. Webpack : Khởi Tạo Project (nghiepuit)

{% embed url="<https://package.json>" %}

```
{
  "name": "webpack",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "scripts": {
    "start": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "webpack": "^4.44.2",
    "webpack-cli": "^3.3.12"
  }
}

```

C:\Users\Administrator\Desktop\webpack\webpack.config.js

```
var path = require('path');
module.exports = {
  mode: 'development',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  }
};
```

C:\Users\Administrator\Desktop\webpack\dist\index.html

```
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Hello Webpack</title>
	<script type="text/javascript" src="bundle.js"></script>
</head>
<body>
	
</body>
</html>
```

C:\Users\Administrator\Desktop\webpack\src\index.js

```
import sum from './math';
const total = sum(3,5);
document.write(total);
```

C:\Users\Administrator\Desktop\webpack\src\math.js

```
const sum = (a, b) => a + b;
export default sum;
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MISo-UPN5grqLhy8Kod%2F-MISrlMP8WM7xVKJVden%2FScreenshot_1.png?alt=media\&token=d9bb30fb-7d39-4d02-be1d-850b97e91496)
