Debug mode

It often happens that a user of your site informs you that an error occurs in some browser: JavaScript does not work or elements have run over each other. But all your CSS and JS code is minified and it is quite difficult for you to find the very place in the source files where this error occurs.

In the future, these problems can be found using Source Maps, but now not all minifiers and browsers support them.

The docpad-plugin-frontend plugin has a special debug mode. Since the structure of all minified files is stored in a JSON directory, it will not be difficult for us to list the source files instead of the compiled one if we need to.

To do this, in DocPad, I create a separate environment, in which I specify the frontendDebug: true option. If the frontendDebug option is true, then the assets () method of the docpad-plugin-frontend plugin will, if possible, return a list of source files instead of minified ones. Example for configuring docpad.coffee:

module.exports = {

environments:

debug:

frontendDebug: true

}

Now when you run DocPad in a debug environment, you will get HTML pages with source CSS and JS files and you can easily find the error:

docpad run --env=debug