[WEBPACK] 12. Webpack : Clean Project (ok)
https://www.youtube.com/watch?v=OL1NDW3z1tY&list=PLJ5qtRQovuEOqsMokakP9ue-y_jXhmCwJ&index=12
Tác dụng xóa file dist đi và tạo lại những file mới :)
C:\Users\Administrator\Desktop\demo\package.json
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"clearn": "rimraf dist",
"build": "npm run clearn && webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"html-webpack-plugin": "^4.5.0",
"rimraf": "^3.0.2",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12"
}
}
C:\Users\Administrator\Desktop\demo\webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
},
plugins: [
new HtmlWebpackPlugin({
title: 'Output Management',
template: 'src/index.html',
filename: 'index.html'
})
],
optimization: {
splitChunks: {
name: 'common'
}
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist')
}
};
C:\Users\Administrator\Desktop\demo\src\index.js
console.log('bbbbbbbbaaaaaaaaadddddd');
C:\Users\Administrator\Desktop\demo\src\index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root">
<p>Lorem ipsum dolor, sit amet.</p>
</div>
</body>
</html>
Previous[WEBPACK] 11. Webpack : Optimize Khi Bundle template (ok)Next[WEBPACK] 12+. Webpack : webpack-dev-server
Last updated