A grunt task that fetches html snapshots of your web app for easier SEO
Makes it easy to provide html snapshots for client side applications so that they can be indexed by web crawlers
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-html-snapshot --save-dev
Run this task with the
grunt htmlSnapshot command.
gruntinitConfightmlSnapshot:all:options://that's the path where the snapshots should be placed//it's empty by default which means they will go into the directory//where your Gruntfile.js is placedsnapshotPath: 'snapshots/'//This should be either the base path to your index.html file//or your base URL. Currently the task does not use it's own//webserver. So if your site needs a webserver to be fully//functional configure it here.sitePath: ''//you can choose a prefix for your snapshots//by default it's 'snapshot_'fileNamePrefix: 'sp_'//by default the task waits 500ms before fetching the html.//this is to give the page enough time to to assemble itself.//if your page needs more time, tweak here.msWaitForPages: 1000//sanitize function to be used for filenames. Converts '#!/' to '_' as default//has a filename argument, must have a return that is a sanitized string//returns 'index.html' if the url is '/', otherwise a prefixif /\//testrequestUrireturn 'index.html';elsereturn requestUrireplace/\//g 'prefix-';//if you would rather not keep the script tags in the html snapshots//set `removeScripts` to true. It's false by defaultremoveScripts: true//set `removeLinkTags` to true. It's false by defaultremoveLinkTags: true//set `removeMetaTags` to true. It's false by defaultremoveMetaTags: true//Replace arbitrary parts of the htmlreplaceStrings:'this': 'will get replaced by this''/old/path/': '/new/path'// allow to add a custom attribute to the bodybodyAttr: 'data-prerendered'//here goes the list of all urls that should be fetchedurls:'''#!/en-gb/showcase'// a list of cookies to be put into the phantomjs cookies jar for the visited pagecookies:"path": "/" "domain": "localhost" "name": "lang" "value": "en-gb";