Skip to content

Commit b8ba928

Browse files
committed
build: Angular2App is now a class, and accepts a set of options for SCSS.
1 parent e201fc5 commit b8ba928

File tree

5 files changed

+353
-338
lines changed

5 files changed

+353
-338
lines changed

lib/broccoli/angular-broccoli-compass.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class CompassPlugin extends Plugin {
4747
}
4848
}
4949

50-
exports.makeBroccoliTree = (sourceDir) => {
50+
exports.makeBroccoliTree = (sourceDir, options) => {
5151
if (sass && compass) {
5252
let compassSrcTree = new Funnel(sourceDir, {
5353
include: ['**/*.scss', '**/*.sass'],
5454
allowEmpty: true
5555
});
5656

57-
return new CompassPlugin([compassSrcTree]);
57+
return new CompassPlugin([compassSrcTree], options);
5858
}
5959
};

lib/broccoli/angular-broccoli-less.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class LESSPlugin extends Plugin {
4242
}
4343
}
4444

45-
exports.makeBroccoliTree = (sourceDir) => {
45+
exports.makeBroccoliTree = (sourceDir, options) => {
4646
if (less) {
4747
let lessSrcTree = new Funnel(sourceDir, {
4848
include: ['**/*.less'],
4949
allowEmpty: true
5050
});
5151

52-
return new LESSPlugin([lessSrcTree]);
52+
return new LESSPlugin([lessSrcTree], options);
5353
}
5454
};

lib/broccoli/angular-broccoli-sass.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const requireOrNull = require('./require-or-null');
55
const Plugin = require('broccoli-caching-writer');
6+
const fs = require('fs');
67
const fse = require('fs-extra');
78
const path = require('path');
89
const Funnel = require('broccoli-funnel');
@@ -24,26 +25,32 @@ class SASSPlugin extends Plugin {
2425
}
2526

2627
build() {
27-
this.listEntries().forEach(e => {
28-
let fileName = path.resolve(e.basePath, e.relativePath);
28+
this.listFiles().forEach(fileName => {
2929
this.compile(fileName, this.inputPaths[0], this.outputPath);
3030
});
3131
}
3232

3333
compile(fileName, inputPath, outputPath) {
34-
let sassOptions = {
35-
file: path.normalize(fileName),
36-
includePaths: this.inputPaths
37-
};
34+
const outSourceName = fileName.replace(inputPath, outputPath);
35+
const outFileName = outSourceName.replace(/\.s[ac]ss$/, '.css');
3836

39-
let result = sass.renderSync(sassOptions);
40-
let filePath = fileName.replace(inputPath, outputPath).replace(/\.s[ac]ss$/, '.css');
37+
const sassOptions = {
38+
file: fileName,
39+
outFile: outFileName,
40+
includePaths: [inputPath].concat(this.options.additionalPaths || [])
41+
};
4142

42-
fse.outputFileSync(filePath, result.css, 'utf8');
43+
const result = sass.renderSync(sassOptions);
44+
fse.outputFileSync(outFileName, result.css, 'utf-8');
45+
if (this.options.copySources) {
46+
fs.symlinkSync(fileName, outSourceName);
47+
}
4348
}
4449
}
4550

46-
exports.makeBroccoliTree = (sourceDir) => {
51+
exports.makeBroccoliTree = (sourceDir, options) => {
52+
options = options || {};
53+
4754
// include sass support only if compass-importer is not installed
4855
let compass = requireOrNull('compass-importer');
4956
if (!compass) {
@@ -56,6 +63,6 @@ exports.makeBroccoliTree = (sourceDir) => {
5663
allowEmpty: true
5764
});
5865

59-
return new SASSPlugin([sassSrcTree]);
66+
return new SASSPlugin([sassSrcTree], options);
6067
}
6168
};

lib/broccoli/angular-broccoli-stylus.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ class StylusPlugin extends Plugin {
4141
}
4242
}
4343

44-
exports.makeBroccoliTree = (sourceDir) => {
44+
exports.makeBroccoliTree = (sourceDir, options) => {
4545
if (stylus) {
4646
let stylusSrcTree = new Funnel(sourceDir, {
4747
include: ['**/*.styl'],
4848
allowEmpty: true
4949
});
5050

51-
return new StylusPlugin([stylusSrcTree]);
51+
return new StylusPlugin([stylusSrcTree], options);
5252
}
5353
};

0 commit comments

Comments
 (0)