Searches for paths within pathseeker blocks and adds them to Grunt variables.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-pathseeker --save-dev
The "pathseeker" task
Pathseeker allows comment blocks to be defined within html files that can be searched for paths to scripts and stylesheets. Those paths are added to config variables that can be used by other task (such as minifiers) within the Gruntfile. This means any new script or stylesheet sources in the html will automatically be picked up by tasks that rely on them.
In your project's Gruntfile, add a section named
pathseeker to the data object passed into
In the target html files, surround
<link> tags with pathseeker comment blocks. Each block is opened with
<!-- pathseeker:name --> and closed with
<!-- pathseekerend -->. Each block must have a unique name specified after the semi-colon. This name will be the name of the variable made available in your Gruntfile.
pathseeker<!-- pathseeker:scripts --><!-- endpathseeker --><!-- pathseeker:styles --><!-- endpathseeker -->
Pathseeker will find all
href paths within each block. These paths will be stored in arrays named after their respective blocks inside a
pathseeker config variable. This config variable can be accessed anywhere in the Gruntfile.
var pf = grunt.config.get('pathseeker'); console.log( pf.styles ); // returns ['test/first.css', 'test/styles/second.css'] from the styles block
These arrays of paths can now be used by other tasks.
NOTE: Remember to run the pathseeker task before any tasks that need to access the
pathseeker config variable.
Prefixes all paths with a base path relative to the target source file. A string will explicitly override the prefix. Setting this to
false will exclude the prefix entirely.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
1.0.0 - Initial release