ButuzGOL
ButuzGOL

Reputation: 1243

Grunt less source maps change path prefix

My config

server: {
    options: {
      sourceMap: true,
      sourceMapFilename: '.tmp/styles/main.css.map',
      sourceMapURL: '/styles/main.css.map'
    },
    files: {
      '.tmp/styles/main.css':
        'src/app/views/styles/application.less'
    }
  },

My structure

 .tmp
 src
 Gruntfile.js

so after calling grunt less:server

I am getting .tmp/styles/main.css.map with attr "sources" everywhere src/ prefix but I want without src/ because server starts from src/*

How can I change it ?

Upvotes: 0

Views: 357

Answers (1)

Bass Jobsen
Bass Jobsen

Reputation: 49044

Since version 1.0.0. grunt-contrib-less accepts the same options as the command line compiler does. You can get a list of these options by running lessc wihtout any argument on your command line:

  --source-map-rootpath=X  Adds this path onto the sourcemap filename and less file paths.

So you should use:

options: {
      sourceMap: true,
      sourceMapFilename: '.tmp/styles/main.css.map',
      sourceMapURL: '/styles/main.css.map',
      sourceMapRootpath: "/app/views/styles/"
    }

Upvotes: 1

Related Questions