1 | 'use strict';
|
2 |
|
3 | var docgen = require('react-docgen');
|
4 | var loaderUtils = require('loader-utils');
|
5 | var path = require('path');
|
6 | module.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 |