Skip to content

Commit

Permalink
fix(plugin-vue): default pug doctype
Browse files Browse the repository at this point in the history
fix #1383
  • Loading branch information
yyx990803 committed Jan 6, 2021
1 parent 956cd2c commit 756a0f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/playground/vue/PreProcessors.vue
Expand Up @@ -6,8 +6,17 @@ p.pug
p.pug-less
| This is rendered from <template lang="pug">
| and styled with <style lang="less">. It should be green.
SlotComponent
template(v-slot:test-slot)
div.pug-slot slot content
</template>

<script setup>
function SlotComponent(_, { slots }) {
return slots['test-slot']()
}
</script>

<style lang="scss">
$color: magenta;
Expand Down
2 changes: 2 additions & 0 deletions packages/playground/vue/__tests__/vue.spec.ts
Expand Up @@ -19,6 +19,8 @@ describe('pre-processors', () => {
expect(await page.textContent('p.pug')).toMatch(
`This is rendered from <template lang="pug">`
)
// #1383 pug default doctype
expect(await page.textContent('.pug-slot')).toMatch(`slot content`)
editFile('PreProcessors.vue', (code) =>
code.replace('Pre-Processors', 'Updated')
)
Expand Down
10 changes: 9 additions & 1 deletion packages/plugin-vue/src/template.ts
Expand Up @@ -133,6 +133,14 @@ export function resolveTemplateCompilerOptions(
transformAssetUrls = assetUrlOptions
}

let preprocessOptions = block.lang && options.template?.preprocessOptions
if (block.lang === 'pug') {
preprocessOptions = {
doctype: 'html',
...preprocessOptions
}
}

return {
...options.template,
id,
Expand All @@ -144,7 +152,7 @@ export function resolveTemplateCompilerOptions(
ssrCssVars: cssVars,
transformAssetUrls,
preprocessLang: block.lang,
preprocessOptions: block.lang && options.template?.preprocessOptions,
preprocessOptions,
compilerOptions: {
...options.template?.compilerOptions,
scopeId: hasScoped ? `data-v-${id}` : undefined,
Expand Down

0 comments on commit 756a0f2

Please sign in to comment.