File tree 4 files changed +35
-4
lines changed
4 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,7 @@ export default {
22
22
color : green ;
23
23
}
24
24
</style >
25
+
26
+ <docs >
27
+ This component is fire. // <-- this should be logged
28
+ </docs >
Original file line number Diff line number Diff line change
1
+ module . exports = function ( source ) {
2
+ this . callback ( null , `export default function (Comp) {
3
+ Comp.mounted = () => console.log(${ JSON . stringify ( source . trim ( ) ) } )
4
+ }` )
5
+ }
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ module.exports = {
39
39
} ,
40
40
'css-loader'
41
41
]
42
+ } ,
43
+ // target <docs> custom blocks
44
+ {
45
+ resourceQuery : / b l o c k T y p e = d o c s / ,
46
+ loader : require . resolve ( './docs-loader' )
42
47
}
43
48
]
44
49
} ,
Original file line number Diff line number Diff line change @@ -160,10 +160,6 @@ const loader: webpack.loader.Loader = function(source) {
160
160
`script.render = render`
161
161
] . join ( '\n' )
162
162
163
- if ( descriptor . customBlocks && descriptor . customBlocks . length ) {
164
- // TODO custom blocks
165
- }
166
-
167
163
// attach scope Id for runtime use
168
164
if ( hasScoped ) {
169
165
code += `\nscript.__scopeId = "data-v-${ id } "`
@@ -187,6 +183,27 @@ const loader: webpack.loader.Loader = function(source) {
187
183
code += `\nscript.__file = ${ JSON . stringify ( path . basename ( resourcePath ) ) } `
188
184
}
189
185
186
+ // custom blocks
187
+ if ( descriptor . customBlocks && descriptor . customBlocks . length ) {
188
+ code += `\n/* custom blocks */\n`
189
+ code +=
190
+ descriptor . customBlocks
191
+ . map ( ( block , i ) => {
192
+ const src = block . attrs . src || resourcePath
193
+ const attrsQuery = attrsToQuery ( block . attrs )
194
+ const blockTypeQuery = `&blockType=${ qs . escape ( block . type ) } `
195
+ const issuerQuery = block . attrs . src
196
+ ? `&issuerPath=${ qs . escape ( resourcePath ) } `
197
+ : ''
198
+ const query = `?vue&type=custom&index=${ i } ${ blockTypeQuery } ${ issuerQuery } ${ attrsQuery } ${ resourceQuery } `
199
+ return (
200
+ `import block${ i } from ${ stringifyRequest ( src + query ) } \n` +
201
+ `if (typeof block${ i } === 'function') block${ i } (script)`
202
+ )
203
+ } )
204
+ . join ( `\n` ) + `\n`
205
+ }
206
+
190
207
// finalize
191
208
code += `\n\nexport default script`
192
209
return code
You can’t perform that action at this time.
0 commit comments