import { loader } from 'webpack' ; import { SFCDescriptor , SFCTemplateCompileOptions , SFCTemplateCompileResults , } from '@vue/compiler-sfc' ; export default function compileTemplateFromDescriptor ( this , sfcDescriptor , compiler ) { if ( ! sfcDescriptor ?. template ?. content ) return ; let content = sfcDescriptor . template . content ; if ( sfcDescriptor . template . lang === 'pug' ) { const pug = require ( 'pug' ) ; content = pug . render ( content , { filename : this . resourcePath } ) ; } const shortFilePath = this . resourcePath . replace ( /^(\.\.[\/\\])+/ , '' ) . replace ( /\\/g , '/' ) ; return compiler . compileTemplate ( { id : shortFilePath , source : content , filename : this . resourcePath , prettify : false , } as unknown as SFCTemplateCompileOptions ) ; }