You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
module.exports = function selectBlock ( |
|
descriptor, |
|
loaderContext, |
|
query, |
|
appendExtension |
|
) { |
|
// template |
|
if (query.type === `template`) { |
|
if (appendExtension) { |
|
loaderContext.resourcePath += '.' + (descriptor.template.lang || 'html') |
|
} |
|
loaderContext.callback( |
|
null, |
|
descriptor.template.content, |
|
descriptor.template.map |
|
) |
|
return |
|
} |
|
|
|
// script |
|
if (query.type === `script`) { |
|
if (appendExtension) { |
|
loaderContext.resourcePath += '.' + (descriptor.script.lang || 'js') |
|
} |
|
loaderContext.callback( |
|
null, |
|
descriptor.script.content, |
|
descriptor.script.map |
|
) |
|
return |
|
} |
|
|
|
// styles |
|
if (query.type === `style` && query.index != null) { |
|
const style = descriptor.styles[query.index] |
|
if (appendExtension) { |
|
loaderContext.resourcePath += '.' + (style.lang || 'css') |
|
} |
|
loaderContext.callback( |
|
null, |
|
style.content, |
|
style.map |
|
) |
|
return |
|
} |
|
|
|
// custom |
|
if (query.type === 'custom' && query.index != null) { |
|
const block = descriptor.customBlocks[query.index] |
|
loaderContext.callback( |
|
null, |
|
block.content, |
|
block.map |
|
) |
|
return |
|
} |
|
}
|
|
|