@@ -32,9 +32,19 @@ var processRequest = function (req, res, next) {
3232 var outputPath = path . join ( specPath , 'build/index.js' ) ;
3333 var insertReactTpl = fs . readFileSync ( path . join ( currentDir , '../templates/insert-react.ejs' ) , 'utf-8' ) ;
3434
35+ if (
36+ ( process . env . NODE_ENV === 'production' || process . env . NODE_ENV === 'presentation' ) &&
37+ fs . existsSync ( outputPath )
38+ ) {
39+ req . specData . renderedHtml += '<script src="build/index.js"></script>' ;
40+ next ( ) ;
41+ return ;
42+ }
43+
3544 fs . outputFileSync ( outputPath , ejs . render ( insertReactTpl ) ) ;
3645
37- //if (false) {
46+ global . __currentSpecInfo__ = req . specData . info ;
47+
3848 if ( fs . existsSync ( jsxFilePath ) ) {
3949 webpack ( {
4050 entry : outputPath ,
@@ -45,14 +55,21 @@ var processRequest = function (req, res, next) {
4555 devtool : "#inline-source-map" ,
4656 module : {
4757 loaders : [
48- { test : / \. j s x ? $ / , exclude : / n o d e _ m o d u l e s / , loader : 'babel-loader' }
58+ // TODO: load stripejs only for styleguide
59+ { test : / \. j s x ? $ / , loader : 'babel-loader!preejs' }
4960 ]
5061 } ,
5162 resolveLoader : {
52- root : path . join ( currentDir , '../../node_modules' )
63+ modulesDirectories : [
64+ path . join ( currentDir , '../../node_modules' ) ,
65+ path . join ( currentDir , '../loaders' ) ,
66+ 'node_modules'
67+ ]
5368 }
54- } , function ( err ) {
69+ } , function ( err , stats ) {
5570 if ( err ) console . log ( 'error' , err ) ;
71+ if ( stats . compilation . errors ) console . log ( stats . compilation . errors . toString ( ) ) ;
72+ if ( stats . compilation . warnings ) console . log ( stats . compilation . warnings . toString ( ) ) ;
5673
5774 next ( ) ;
5875 } ) ;
0 commit comments