[WEBPACK] 2. Webpack : Khởi Tạo Project (nghiepuit)
https://www.youtube.com/watch?v=-yPEoARR9nM&list=PLJ5qtRQovuEOqsMokakP9ue-y_jXhmCwJ&index=2
{
"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;

PreviousWhat is the difference between @babel/core and babel-core? (ok)Next[WEBPACK] 3. Webpack : Apply Babel Cho Project (nghiepuit)
Last updated
Was this helpful?