Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assign a different location for the source map file #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ 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
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";
```

Expand Down
14 changes: 7 additions & 7 deletions lib/less-autocompile-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) ->
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down