Skip to content

Commit

Permalink
Write docs script to get react-static build failure to error in terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed May 5, 2022
1 parent 3ec5d68 commit cec4e61
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/node.api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default () => ({
webpack: (config) => {
// Error the build on failures
config.bail = true;

// react-static's config.resolve.modules field is causing issues with
// the correct node_module resolution, so we fix that here
// https://github.com/react-static/react-static/issues/1423
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"license": "MIT",
"scripts": {
"start": "node --max-old-space-size=2048 node_modules/react-static/bin/react-static start",
"build": "react-static build",
"build": "node ./scripts/build.js",
"clean": "rimraf dist",
"serve": "formideploy serve --port 4000",
"deploy:stage": "formideploy deploy --staging",
Expand Down
22 changes: 22 additions & 0 deletions docs/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Wrap `react-static build` to fail on build error.
*/
const build = require("react-static/lib/commands/build").default;

const { log } = console; // eslint-disable-line no-undef

// Main.
const main = () => build({
packageConfig: {}
});

if (require.main === module) {
main()
.then(() => {
log("Build finished.");
})
.catch(() => {
log("Build failed");
process.exit(-1);
});
}
2 changes: 1 addition & 1 deletion docs/static.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (stage === "development") {
chokidar.watch("src/content/**/*.md").on("all", () => rebuildRoutes());
}

export default {
module.exports = {
getSiteData: () => siteData,
paths: {
root: process.cwd(), // The root of your project. Don't change this unless you know what you're doing.
Expand Down

0 comments on commit cec4e61

Please sign in to comment.