Skip to content

Commit

Permalink
Merge pull request #40 from fson/show-errors
Browse files Browse the repository at this point in the history
Show errors during static page generation
  • Loading branch information
KyleAMathews committed Sep 23, 2015
2 parents 726a4be + 78b28e5 commit 49fa931
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
38 changes: 22 additions & 16 deletions lib/utils/static-entry.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,28 @@ module.exports = (locals, callback) ->
else
childPages = []

body = React.renderToString(
<Handler
config={config}
pages={pages}
page={page}
childPages={childPages}
state={state}
/>
)
body = ''
html = ''
try
body = React.renderToString(
<Handler
config={config}
pages={pages}
page={page}
childPages={childPages}
state={state}
/>
)

html = "<!DOCTYPE html>\n" + React.renderToStaticMarkup(
<HTML
config={config}
page={page}
body={body}
/>
)
html = "<!DOCTYPE html>\n" + React.renderToStaticMarkup(
<HTML
config={config}
page={page}
body={body}
/>
)
catch e
console.error e.stack
return callback(e)

callback null, html
6 changes: 5 additions & 1 deletion lib/utils/static-generation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ module.exports = (program, callback) ->
compilerConfig = webpackConfig(program, directory, 'static', null, routes)

webpack(compilerConfig).run (err, stats) ->
callback(err, stats)
if err
return callback(err, stats)
if stats.hasErrors()
return callback('Error: ' + stats.toJson().errors, stats)
callback(null, stats)

0 comments on commit 49fa931

Please sign in to comment.