File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
2- "name" : " @storybook /react" ,
3- "version" : " 3.0.0-rc.0 " ,
2+ "name" : " @enjoylife /react" ,
3+ "version" : " 3.0.0-rc.1 " ,
44 "description" : " Storybook for React: Develop React Component in isolation with Hot Reloading." ,
55 "license" : " MIT" ,
66 "main" : " dist/client/index.js" ,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const managerUrlsFromAssets = assets => {
2828} ;
2929
3030export default function ( data ) {
31- const { assets, publicPath } = data ;
31+ const { assets, publicPath, bodyScript } = data ;
3232
3333 const managerUrls = managerUrlsFromAssets ( assets ) ;
3434
@@ -73,6 +73,7 @@ export default function(data) {
7373 </head>
7474 <body style="margin: 0;">
7575 <div id="root"></div>
76+ ${ bodyScript }
7677 <script src="${ url . resolve ( publicPath , managerUrls . js ) } "></script>
7778 </body>
7879 </html>
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import getBaseConfig from './config/webpack.config';
66import loadConfig from './config' ;
77import getIndexHtml from './index.html' ;
88import getIframeHtml from './iframe.html' ;
9- import { getHeadHtml , getMiddleware } from './utils' ;
9+ import { getHeadHtml , getBodyScript , getMiddleware } from './utils' ;
1010
1111export default function ( configDir ) {
1212 // Build the webpack configuration using the `getBaseConfig`
@@ -36,7 +36,8 @@ export default function(configDir) {
3636 middlewareFn ( router ) ;
3737
3838 router . get ( '/' , ( req , res ) => {
39- res . send ( getIndexHtml ( { publicPath } ) ) ;
39+ const bodyScript = getBodyScript ( configDir )
40+ res . send ( getIndexHtml ( { publicPath, bodyScript } ) ) ;
4041 } ) ;
4142
4243 router . get ( '/iframe.html' , ( req , res ) => {
Original file line number Diff line number Diff line change @@ -15,6 +15,17 @@ export function getHeadHtml(configDirPath) {
1515 return headHtml ;
1616}
1717
18+ export function getBodyScript ( configDirPath ) {
19+ const scriptPath = path . resolve ( configDirPath , 'bodyscript.html' ) ;
20+ let scriptHtml = '' ;
21+ if ( fs . existsSync ( scriptPath ) ) {
22+ scriptHtml = fs . readFileSync ( scriptPath , 'utf8' ) ;
23+ }
24+
25+ return scriptHtml ;
26+ }
27+
28+
1829export function getEnvConfig ( program , configEnv ) {
1930 Object . keys ( configEnv ) . forEach ( fieldName => {
2031 const envVarName = configEnv [ fieldName ] ;
You can’t perform that action at this time.
0 commit comments