in Web & Tech

Using Node.js modules in your Drupal Themes

As my frontend development workflow gets more and more dependent on Grunt and node.js there are are issues coming up when Drupal tries to parse .info files from theme directories. I’ve had a hard time working around this by putting Gruntfile.js and package.json in a hidden subdirectory of my theme, but this resulted in a lot of broken Grunt tasks (and it’s basically yet another hack because it simply relies on the fact that Drupal doesn’t scan directories starting with a dot).

So I went the easy yet dirty way and hacked the Drupal core. Yes, yes, it’s bad, but I didn’t see another way without wasting yet even more hours just to be able to employ a modern frontend workflow.

All I had to do was changing the nomask value in line 2109 of includes/file.inc to 'nomask' => '/(\.\.?|CVS|node_modules)$/',

This makes sure Drupal won’t parse the .info files from any node_modules folder, et voilĂ , all Grunt tasks and Drupal work peacefully side by side!

Source: https://www.drupal.org/node/2329453#comment-9360519

Write a Comment

Comment