diff --git a/README.md b/README.md index 3c9840b..17267e6 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ Auto compile LESS file on save. Add the parameters on the first line of the LESS file. ``` -out (string): path of CSS file to create -sourcemap (bool): create sourcemap file -compress (bool): compress CSS file -main (string): path to your main LESS file to be compiled +out (string) : path of CSS file to create +sourcemap (bool/string) : path or boolean to create sourcemap file. (path is relative to the 'out' path) +compress (bool) : compress CSS file +main (string) : path to your main LESS file to be compiled ``` ## Example @@ -18,6 +18,12 @@ less/styles.less ```scss // out: ../css/styles.css, sourcemap: true, compress: true +@import "my/components/select.less"; +``` +or +```scss +// out: ../css/styles.css, sourcemap: ../maps/styles.css.map, compress: true + @import "my/components/select.less"; ``` diff --git a/lib/less-autocompile-view.coffee b/lib/less-autocompile-view.coffee index fdb99c7..032b481 100644 --- a/lib/less-autocompile-view.coffee +++ b/lib/less-autocompile-view.coffee @@ -25,7 +25,7 @@ class LessAutocompileView @getParams @filePath, (params) => @compileLess params - writeFiles: (output, newPath, newFile) -> + writeFiles: (output, newPath, newFile, mapPath, mapFile) -> async.series css: (callback) => if output.css @@ -35,10 +35,8 @@ class LessAutocompileView callback null, null map: (callback) => if output.map - newFile = "#{newFile}.map" - - @writeFile output.map, newPath, newFile, -> - callback null, newFile + @writeFile output.map, mapPath, mapFile, -> + callback null, mapFile else callback null, null , (err, results) -> @@ -70,7 +68,7 @@ class LessAutocompileView paths: [path.dirname path.resolve(params.file)] filename: path.basename params.file compress: if params.compress == 'true' then true else false - sourceMap: if params.sourcemap == 'true' then {} else false + sourceMap: if params.sourcemap? then (if params.sourcemap == 'true' then {sourceMapURL: path.basename params.out + ".map"} else {sourceMapURL: params.sourcemap}) else false rl = readline.createInterface input: fs.createReadStream params.file @@ -92,8 +90,10 @@ class LessAutocompileView .then (output) => newFile = path.resolve(path.dirname(params.file), params.out) newPath = path.dirname newFile + mapFile = if output.map? then path.resolve path.dirname(params.file), path.dirname(params.out), optionsLess.sourceMap?.sourceMapURL + mapPath = path.dirname mapFile - @writeFiles output, newPath, newFile + @writeFiles output, newPath, newFile, mapPath, mapFile , (err) -> if err atom.notifications.addError err.message,