8000 feat(cli-service): add inline loader support for html-webpack-plugin by ylc395 · Pull Request #5997 · vuejs/vue-cli · GitHub
[go: up one dir, main page]

Skip to content

feat(cli-service): add inline loader support for html-webpack-plugin #5997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading 8000
Diff view
Diff view
Next Next commit
feat(cli-service): add inline loader support for html-webpack-plugin
  • Loading branch information
ylc395 committed Oct 23, 2020
commit 9a58fe628ac7cd3e4068fd5e828efd38b2d69311
9 changes: 7 additions & 2 deletions packages/@vue/cli-service/lib/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,20 @@ module.exports = (api, options) => {
const entries = Array.isArray(entry) ? entry : [entry]
webpackConfig.entry(name).merge(entries.map(e => api.resolve(e)))

// test whether use 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 inlineLoaderReg = /[-!]?!.+!/
const isWithInlineLoader = /^[-!]?!/.test(template)

// resolve page index template
const hasDedicatedTemplate = fs.existsSync(api.resolve(template))
const hasDedicatedTemplate = fs.existsSync(api.resolve(isWithInlineLoader ? template.replace(inlineLoaderReg, '') : template))
const templatePath = hasDedicatedTemplate
? template
: fs.existsSync(htmlPath)
? htmlPath
: defaultHtmlPath

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

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