Closed
Description
Version
3.0.0-beta.15
Reproduction link
https://github.com/wind930/vue-multi-page-test
Steps to reproduce
- vue create my-project or create project by vue ui
- create vue.config.js and some page in anywhere
module.exports = {
chainWebpack: config => {
config
.entry("app")
.clear()
.end();
},
pages: {
index: {
entry: "src/pages/index/index.ts",
template: "src/pages/index/index.html",
filename: "index.html",
title: "Home"
},
login: {
entry: "src/pages/login/index.ts",
template: "src/pages/login/index.html",
filename: "login.html",
title: "Login"
}
}
};
- exec command : vue-cli-service inspect --mode development, you will found this:
...
/* config.plugin('html-index') */
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
chunks: [
'chunk-vendors',
'chunk-common',
'index'
],
template: 'src/pages/index/index.html',
filename: 'index.html',
}
),
/* config.plugin('html-login') */
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
chunks: [
'chunk-vendors',
'chunk-common',
'login'
],
template: 'src/pages/login/index.html',
filename: 'login.html',
}
),
...
- then you will found the page use the default title 『webpack app 』
What is expected?
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
chunks: [
'chunk-vendors',
'chunk-common',
'index'
],
template: 'src/pages/index/index.html',
filename: 'index.html',
title : "Home"
}
),
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
chunks: [
'chunk-vendors',
'chunk-common',
'login'
],
template: 'src/pages/login/index.html',
filename: 'login.html',
title : "Login"
}
),
What is actually happening?
The compiled HTML uses the default title attribute "webpack app".
Before you can solve this bug, you can still use chainWebpack to modify plug-in options, but I think this is redundant. There should be webpack-cli automatic injection.
module.exports = {
chainWebpack: config => {
config
.entry("app")
.clear()
.end();
config.plugin("html-login").tap(function(args) {
args[0].title = "Login";
return args;
});
config.plugin("html-index").tap(function(args) {
args[0].title = "Home";
return args;
});
},
pages: {
index: {
entry: "src/pages/index/index.ts",
template: "src/pages/index/index.html",
filename: "index.html",
title: "Home"
},
login: {
entry: "src/pages/login/index.ts",
template: "src/pages/login/index.html",
filename: "login.html",
title: "Login"
}
}
};
Metadata
Metadata
Assignees
Labels
No labels