Skip to content

Commit af9a4f9

Browse files
Maddfilipesilva
authored andcommitted
fix(sass): don't compile partials
1 parent e190168 commit af9a4f9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/broccoli/angular-broccoli-sass.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ class SASSPlugin extends Plugin {
2626

2727
build() {
2828
this.listFiles().forEach(fileName => {
29-
// Normalize is necessary for changing `\`s into `/`s on windows.
30-
this.compile(path.normalize(fileName),
31-
path.normalize(this.inputPaths[0]),
32-
path.normalize(this.outputPath));
29+
// We skip compiling partials (_*.scss files)
30+
if(!/^_+.*.s[ac]ss$/.test(path.basename(fileName))) {
31+
// Normalize is necessary for changing `\`s into `/`s on windows.
32+
this.compile(path.normalize(fileName),
33+
path.normalize(this.inputPaths[0]),
34+
path.normalize(this.outputPath));
35+
}
3336
});
3437
}
3538

tests/e2e/e2e_workflow.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,33 @@ describe('Basic end-to-end Workflow', function () {
291291
let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component');
292292
let cssFile = path.join(componentPath, 'test-component.component.css');
293293
let scssFile = path.join(componentPath, 'test-component.component.scss');
294+
let scssPartialFile = path.join(componentPath, '_test-component.component.partial.scss');
295+
296+
let scssPartialExample = '.partial {\n @extend .outer;\n }';
297+
fs.writeFileSync(scssPartialFile, scssPartialExample, 'utf8');
298+
expect(existsSync(scssPartialFile)).to.be.equal(true);
294299

295300
expect(existsSync(componentPath)).to.be.equal(true);
296301
sh.mv(cssFile, scssFile);
297302
expect(existsSync(scssFile)).to.be.equal(true);
298303
expect(existsSync(cssFile)).to.be.equal(false);
299-
let scssExample = '.outer {\n .inner { background: #fff; }\n }';
304+
let scssExample = '@import "test-component.component.partial";\n\n.outer {\n .inner { background: #fff; }\n }';
300305
fs.writeFileSync(scssFile, scssExample, 'utf8');
301306

302307
sh.exec(`${ngBin} build`);
303308
let destCss = path.join(process.cwd(), 'dist', 'app', 'test-component', 'test-component.component.css');
304309
expect(existsSync(destCss)).to.be.equal(true);
305310
let contents = fs.readFileSync(destCss, 'utf8');
306311
expect(contents).to.include('.outer .inner');
312+
expect(contents).to.include('.partial .inner');
307313

308314
sh.rm('-f', destCss);
309315
process.chdir('src');
310316
sh.exec(`${ngBin} build`);
311317
expect(existsSync(destCss)).to.be.equal(true);
312318
contents = fs.readFileSync(destCss, 'utf8');
313319
expect(contents).to.include('.outer .inner');
320+
expect(contents).to.include('.partial .inner');
314321

315322
process.chdir('..');
316323
sh.exec('npm uninstall node-sass', { silent: true });

0 commit comments

Comments
 (0)