Skip to content

Commit 756a0f2

Browse files
committed
fix(plugin-vue): default pug doctype
fix #1383
1 parent 956cd2c commit 756a0f2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

packages/playground/vue/PreProcessors.vue

+9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ p.pug
66
p.pug-less
77
| This is rendered from <template lang="pug">
88
| and styled with <style lang="less">. It should be green.
9+
SlotComponent
10+
template(v-slot:test-slot)
11+
div.pug-slot slot content
912
</template>
1013

14+
<script setup>
15+
function SlotComponent(_, { slots }) {
16+
return slots['test-slot']()
17+
}
18+
</script>
19+
1120
<style lang="scss">
1221
$color: magenta;
1322

packages/playground/vue/__tests__/vue.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ describe('pre-processors', () => {
1919
expect(await page.textContent('p.pug')).toMatch(
2020
`This is rendered from <template lang="pug">`
2121
)
22+
// #1383 pug default doctype
23+
expect(await page.textContent('.pug-slot')).toMatch(`slot content`)
2224
editFile('PreProcessors.vue', (code) =>
2325
code.replace('Pre-Processors', 'Updated')
2426
)

packages/plugin-vue/src/template.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ export function resolveTemplateCompilerOptions(
133133
transformAssetUrls = assetUrlOptions
134134
}
135135

136+
let preprocessOptions = block.lang && options.template?.preprocessOptions
137+
if (block.lang === 'pug') {
138+
preprocessOptions = {
139+
doctype: 'html',
140+
...preprocessOptions
141+
}
142+
}
143+
136144
return {
137145
...options.template,
138146
id,
@@ -144,7 +152,7 @@ export function resolveTemplateCompilerOptions(
144152
ssrCssVars: cssVars,
145153
transformAssetUrls,
146154
preprocessLang: block.lang,
147-
preprocessOptions: block.lang && options.template?.preprocessOptions,
155+
preprocessOptions,
148156
compilerOptions: {
149157
...options.template?.compilerOptions,
150158
scopeId: hasScoped ? `data-v-${id}` : undefined,

0 commit comments

Comments
 (0)