Skip to content

Instantly share code, notes, and snippets.

@yanwei07
Created November 29, 2019 03:43
Show Gist options
  • Save yanwei07/26b61bf2440f5df9beb47af4086e182a to your computer and use it in GitHub Desktop.
Save yanwei07/26b61bf2440f5df9beb47af4086e182a to your computer and use it in GitHub Desktop.
vue for multiple page
// ...
const config = {
// ...
}
// ...
glob.sync('./src/pages/**/app.html').forEach(path => {
// Get all the html template files and forEach them
// E.g, path = './src/pages/user/index/app.html'
const chunk = path.split('./src/pages/')[1].split('/app.html')[0]
// E,g. the chunk will be 'user/login'
const filename = chunk + '.html'
// E.g, the html filename will be 'user/index.html' in the 'dist' folder
const htmlConf = {
filename: filename,
template: path,
inject: 'body',
favicon: './src/assets/img/logo.png',
hash: process.env.NODE_ENV === 'production',
chunks: ['vendors', chunk]
}
config.plugins.push(new HtmlWebpackPlugin(htmlConf))
})
作者:geekarl
链接:https://juejin.im/post/5a56c874518825732d7f80d2
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment