Tell us what you would expect the html-webpack-plugin should.
when you set a template in your options, the html generated by plugin should insert the title your set;
Tell us what the html-webpack-plugin does instead.
title is not work
Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:
mac
node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
npm --version
npm ls webpack
npm ls html-webpack-plugin
Copy the minimal webpack.config.js to produce this issue:
module.exports = {
entry: 'app.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
module: {
rules: [
...
]
}
plugins: [
new HtmlWebpackPlugin(),
...
]
}
Copy your template file if it is part of this issue:
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
</head>
<body>
</body>
</html>
Add any other context about the problem here.
`
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './pages/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js'
},
mode: 'none',
module:{
rules:[
{
test: /.txt$/,
use:['raw-loader']
}
]
},
plugins:[
new HtmlWebpackPlugin({
title: 'My app',
filename: 'assets/index.html',
// template: './pages/index.html',
inject: 'body',
minify: {
// collapseWhitespace: true,
// removeComments: true,
// removeRedundantAttributes: true,
// removeScriptTypeAttributes: true,
// removeStyleLinkTypeAttributes: true,
// useShortDoctype: true
},
hash: true
})
]
}
`
The title is part of the default template if you want to use your own you have to set the title by yourself - if think of it like a preset vs a custom solution
Most helpful comment
The title is part of the default template if you want to use your own you have to set the title by yourself - if think of it like a preset vs a custom solution
https://github.com/jantimon/html-webpack-plugin/blob/25465510df1633f76005f430b098cc7783e0495b/default_index.ejs#L5