Skip to content

Commit

Permalink
feat(cli-service): add inline loader support for html-webpack-plugin (#…
Browse files Browse the repository at this point in the history
…5997)

Close #2697
  • Loading branch information
ylc395 authored Apr 5, 2021
1 parent 89af6c5 commit de175d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@vue/cli-service/lib/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,19 @@ module.exports = (api, options) => {
const entries = Array.isArray(entry) ? entry : [entry]
webpackConfig.entry(name).merge(entries.map(e => api.resolve(e)))

// trim inline loader
// * See https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md#2-setting-a-loader-directly-for-the-template
const templateWithoutLoader = template.replace(/^.+!/, '').replace(/\?.+$/, '')

// resolve page index template
const hasDedicatedTemplate = fs.existsSync(api.resolve(template))
const hasDedicatedTemplate = fs.existsSync(api.resolve(templateWithoutLoader))
const templatePath = hasDedicatedTemplate
? template
: fs.existsSync(htmlPath)
? htmlPath
: defaultHtmlPath

publicCopyIgnore.push(api.resolve(templatePath).replace(/\\/g, '/'))
publicCopyIgnore.push(api.resolve(templateWithoutLoader).replace(/\\/g, '/'))

// inject html plugin for the page
const pageHtmlOptions = Object.assign(
Expand Down

0 comments on commit de175d4

Please sign in to comment.