File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,17 @@ module.exports = function(grunt) {
155155 src : 'test/fixtures/style3.less' ,
156156 dest : 'tmp/sourceMapWithCustomURL.css'
157157 } ,
158+ sourceMapURLFunction : {
159+ options : {
160+ sourceMap : true ,
161+ sourceMapFilename : 'tmp/maps/sourceMapURLFunction.css.map' ,
162+ sourceMapURL : function ( /* dest */ ) {
163+ return '../maps/sourceMapURLFunction.css.map' ;
164+ }
165+ } ,
166+ src : 'test/fixtures/style3.less' ,
167+ dest : 'tmp/sourceMapURLFunction.css'
168+ } ,
158169 sourceMapBasepath : {
159170 options : {
160171 sourceMap : true ,
Original file line number Diff line number Diff line change @@ -126,6 +126,14 @@ module.exports = function(grunt) {
126126 }
127127 }
128128
129+ if ( typeof options . sourceMapURL === 'function' ) {
130+ try {
131+ options . sourceMapURL = options . sourceMapURL ( destFile ) ;
132+ } catch ( e ) {
133+ grunt . fail . warn ( wrapError ( e , 'Generating sourceMapURL failed.' ) ) ;
134+ }
135+ }
136+
129137 if ( typeof options . sourceMap === 'boolean' && options . sourceMap ) {
130138 options . sourceMap = {
131139 sourceMapBasepath : options . sourceMapBasepath ,
Original file line number Diff line number Diff line change @@ -135,6 +135,13 @@ exports.less = {
135135 test . ok ( actual . indexOf ( '/*# sourceMappingURL=custom/url/for/sourceMap.css.map' ) !== - 1 , 'compiled file should have a custom source map URL.' ) ;
136136 test . done ( ) ;
137137 } ,
138+ sourceMapURLFunction : function ( test ) {
139+ test . expect ( 1 ) ;
140+
141+ var actual = read ( 'tmp/sourceMapURLFunction.css' ) ;
142+ test . ok ( actual . indexOf ( '/*# sourceMappingURL=../maps/sourceMapURLFunction.css.map' ) !== - 1 , 'compiled file should have a dynamic source map URL.' ) ;
143+ test . done ( ) ;
144+ } ,
138145 sourceMapBasepath : function ( test ) {
139146 test . expect ( 1 ) ;
140147
You can’t perform that action at this time.
0 commit comments