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'
}
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
open: true
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist')
}
};
{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"clearn": "rimraf dist",
"build": "npm run clearn && webpack",
"server": "webpack-dev-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"html-webpack-plugin": "^4.5.0",
"rimraf": "^3.0.2",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
}
}
console.log('bbbbbbbbaaaaaaaaadddddd');
<!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>