tmcw / docbox

REST API documentation generator
ISC License
1.14k stars 190 forks source link

The build script isn't overwriting the index.html file #7

Closed JamesChevalier closed 8 years ago

JamesChevalier commented 8 years ago

In my experience so far, the build script is not overwriting the index.html file after its first run (so, the first run does overwrite the index.html file).

I think the cause is that the render.js file is looking to specifically overwrite the instance of APP in the index.html file. The problem seems to be that the first run of the build script replaces APP with the compiled contents of the markdown files, so subsequent attempts to replace APP can't succeed.

I've gotten around this by changing the build script to output to a different file:

"build": "NODE_ENV=production browserify src/index.js | uglifyjs -c -m > bundle.js && npm run prerender -- release.html"

I can't really rationalize why that works, though, since the release.html file doesn't include APP either. ¯_(ツ)_/¯

Assuming I'm not just doing something/everything wrong, can I provide any more information or run any particular tests to help you with this?

tmcw commented 8 years ago

This needs some better description! Specifically I need to figure out how to better explain this and make it runnable for everyone.


The gist is that, for the Mapbox use case, the build script only runs in the build phase. We have a service that works a lot like GitHub Pages but it also runs npm install & npm run build - so for a bunch of projects, we use npm scripts to do our build processes and avoid commiting any 'dist' or built files to the repository. So the APP hack is geared for that and is the simplest possible solution.

I think writing a re-runnable script is possible by replacing the APP string-replace with, for instance, <!-- start --> and end comments that wouldn't be overwritten by the rendering process.