node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »



A grunt plugin for convert relative path to absolutely.


This tool is used to change a resource's path from relative to absolute.


<img src='./dev/pic1.jpg'/>

converts to:

<img src=''/>

File type is configurable, both main file and resource file.

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile.js 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-path-absolutely --save-dev

Once the plugin has been installed, it may be enabled inside your gruntfile.js with this line:


Suppose the project deployment is something like this:


Then, add and configure it to your Gruntfile.js:

grunt.initConfig( {
                //resource file's actual root, which part you want it to replaced by 'releaseRoot' 
                //the absolute root you wanted 
                //what resource need in  to change the root 
            files: [ {
                expand: true,
                //main file(eg:index.html) rootdir 
                src: [ 'dev/**/*.html' ],
                //output main file 
                dest: 'release/view'
            } ]
    } );

Abspath task

Run this task with the grunt abspath command.