Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Added ability to disable map files as a setting #9

Merged
merged 2 commits into from
Aug 25, 2017
Merged
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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
],
"default": null,
"description": "This setting is useful when you deals with only few of sass files. Only mentioned Sass files will be included. \nNOTE: No need to include partial sass files."
},
"liveSassCompile.settings.generateMap": {
"type": [
"boolean"
],
"default": true,
"description": "Choose whether this script automatically comiles map files for the CSS generated from the compiler."
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/appModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class AppModel {
* @param options - Object - It includes target CSS style and some more.
*/
private GenerateCssAndMap(SassPath: string, targetCssUri: string, mapFileUri: string, options) {
let generateMap = helper_1.Helper.getConfigSettings('generateMap');
return new Promise(resolve => {
SassHelper.instance.compileOne(SassPath, options)
.then((result) => {
Expand All @@ -146,11 +147,15 @@ export class AppModel {
else {
let promises: Promise<IFileResolver>[] = [];
let mapFileTag = `/*# sourceMappingURL= ${path.basename(targetCssUri)}.map */`
promises.push(FileHelper.Instance.writeToOneFile(targetCssUri, `${result.text} \n\n ${mapFileTag}`));

let map = this.GenerateMapObject(result.map, targetCssUri);
promises.push(FileHelper.Instance.writeToOneFile(mapFileUri,
JSON.stringify(map, null, 4)));
if (generateMap === false) {
promises.push(FileHelper_1.FileHelper.Instance.writeToOneFile(targetCssUri, `${result.text}`));
}
else {
promises.push(FileHelper_1.FileHelper.Instance.writeToOneFile(targetCssUri, `${result.text} \n\n ${mapFileTag}`));
let map = this.GenerateMapObject(result.map, targetCssUri);
promises.push(FileHelper_1.FileHelper.Instance.writeToOneFile(mapFileUri, JSON.stringify(map, null, 4)));
}

Promise.all(promises).then(fileResolvers => {
OutputWindow.Show("Generated :", null, false, false);
Expand Down