Search code examples
node.jsgruntjswiredepgruntfile

wiredep is returing physical path, instead of relative path


I'm trying to get the itens from wiredep in my gruntfile, but it is always returning a physical path, like: "D:\folder\folder\file.css", while in the documentation it says that it will return a relative path (https://github.com/taptapship/wiredep#programmatic-access).

My code is:

in gruntfile:

var myCss = require('wiredep')().css

in my index.html i have:

<!-- bower:css -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="bower_components/normalize.css/normalize.css" />
    <link rel="stylesheet" href="bower_components/angular-chart.js/dist/angular-chart.css" />
    <link rel="stylesheet" href="bower_components/angular-snap/angular-snap.css" />
    <link rel="stylesheet" href="bower_components/ionicons/css/ionicons.css" />
    <link rel="stylesheet" href="bower_components/angular-carousel/dist/angular-carousel.css" />
    <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
    <!-- endbower -->

I want it to return an array with the path as is, ex: "bower_components/font-awesome/css/font-awesome.css"


Solution

  • Check the option ignorePath of wirerep configuration parameter. To give you more detail you should provide the full paths structure of your project folder but try something like this

    var myCss = require('wiredep')({ignorePath: '/../../'}).css