Last active
May 12, 2020 06:32
-
-
Save robdodson/897af7ab00019364fe0589e7c8999ae0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(eleventyConfig) { | |
eleventyConfig.addFilter('debug', function(...args) { | |
debugger; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my project", | |
"scripts": { | |
"debug:eleventy": "node --inspect-brk ./node_modules/.bin/eleventy", | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ data | debug }} |
oh maybe read this too: https://itnext.io/the-absolute-easiest-way-to-debug-node-js-with-vscode-2e02ef5b1bad
I forgot that I have the extension they mention in that post installed so my VS Code automatically connects the debugger if I start node with the --inspect-brk
flag using VS Code's integrated terminal.
Thank you
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running node with
node --inspect-brk
will put it into debug mode. If you have a page that uses thedebug
filter, then eleventy will halt execution when it processes that page. Whatever data you pass to that debug filter will show up when the debugger hits the debug statement on line 3 of.eleventy.js
.This post is a bit old but it explains the process: https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
If you haven't used the node debugger before I'd suggest first creating a plain
index.js
file, and writing a few statements and adding adebugger
statement in there to halt execution. See if you can get that working withnode --inspect
ornode --inspect-brk
. Once that seems to do what you expect, then try with eleventy. hope that helps!