Relativize absolute paths in HTML and CSS
Relativize absolute paths in HTML and CSS.
You built some static website. Maybe you're gonna host it on gh-pages. Maybe you're squating a stellar domain name, but you'd rather review the site on
<yourname>.github.io/<yourproject> before you repoint DNS. How do you make your pages work from both
Add something like this to your Gruntfile:
gruntloadNpmTasks'grunt-relative-root';gruntinitConfigrelativeRoot:yourTarget:options:root: 'public'files:expand: truecwd: '<%= relativeRoot.yourTarget.options.root %>'src: '*.css' '*.html'dest: 'out/'
Grunt at least a
npm install grunt-relative-root --save-dev
Local directory used as the base for relative paths. If
root: 'public' then the URL
'/images/logo.png' in the file
'public/events/solstice.html' will be rewritten as