UNPKG

613 BJavaScriptView Raw
1'use strict';
2
3var docgen = require('react-docgen');
4var loaderUtils = require('loader-utils');
5var path = require('path');
6module.exports = function (source) {
7 this.cacheable && this.cacheable();
8 var query = loaderUtils.parseQuery(this.query);
9
10 var value = {};
11 try {
12 value = docgen.parse(source);
13 } catch (e) {
14 console.log('ERROR in docgen-loader', e);
15 }
16 var comNameAry = this.resourcePath.split(path.sep);
17 var comName = comNameAry[comNameAry.length - 1];
18 var name = comName.substring(0, comName.lastIndexOf('.'));
19 return source + ';' + name + '.propsObj=' + JSON.stringify(value);
20};
\No newline at end of file