From de175d4f8e308fa2cae190d9c13bb2ec1700cc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A1=E5=B1=B1=E7=94=B5=E8=BD=A6?= Date: Mon, 5 Apr 2021 21:37:51 +0800 Subject: [PATCH] feat(cli-service): add inline loader support for html-webpack-plugin (#5997) Close #2697 --- packages/@vue/cli-service/lib/config/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-service/lib/config/app.js b/packages/@vue/cli-service/lib/config/app.js index 978d4faacb..2fcbfa8a21 100644 --- a/packages/@vue/cli-service/lib/config/app.js +++ b/packages/@vue/cli-service/lib/config/app.js @@ -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(