import webpack = require ( 'webpack' ) ; import type { SFCDescriptor } from 'vue/compiler-sfc' ; import type { ParsedUrlQuery } from 'querystring' ; import { resolveScript } from './resolveScript' ; import type { VueLoaderOptions } from 'src' ; export function selectBlock ( descriptor , scopeId , options , loaderContext , query , appendExtension ) { if ( query . type === `template` ) { const template = descriptor . template ! ; if ( appendExtension ) { loaderContext . resourcePath += '.' + ( template . lang || 'html' ) ; } loaderContext . callback ( null , template . content , template . map ) ; return ; } if ( query . type === `script` ) { const script = resolveScript ( descriptor , scopeId , options , loaderContext ) ! ; if ( appendExtension ) { loaderContext . resourcePath += '.' + ( script . lang || 'js' ) ; } loaderContext . callback ( null , script . content , script . map ) ; return ; } if ( query . type === `style` && query . index != null ) { const style = descriptor . styles [ Number ( query . index ) ] ; if ( appendExtension ) { loaderContext . resourcePath += '.' + ( style . lang || 'css' ) ; } loaderContext . callback ( null , style . content , style . map ) ; return ; } if ( query . type === 'custom' && query . index != null ) { const block = descriptor . customBlocks [ Number ( query . index ) ] ; loaderContext . callback ( null , block . content , block . map ) ; } }