forked from vuejs/vue-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.js
46 lines (43 loc) · 1.05 KB
/
select.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module.exports = function selectBlock (descriptor, loaderContext, query) {
// template
if (query.type === `template`) {
loaderContext.resourcePath += '.' + (descriptor.template.type || 'template')
loaderContext.callback(
null,
descriptor.template.content,
descriptor.template.map
)
return
}
// script
if (query.type === `script`) {
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]
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
}
}