Skip to content

Commit

Permalink
fix(sass): don't compile partials
Browse files Browse the repository at this point in the history
  • Loading branch information
Madd authored and filipesilva committed Jul 4, 2016
1 parent e190168 commit af9a4f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/broccoli/angular-broccoli-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ class SASSPlugin extends Plugin {

build() {
this.listFiles().forEach(fileName => {
// Normalize is necessary for changing `\`s into `/`s on windows.
this.compile(path.normalize(fileName),
path.normalize(this.inputPaths[0]),
path.normalize(this.outputPath));
// We skip compiling partials (_*.scss files)
if(!/^_+.*.s[ac]ss$/.test(path.basename(fileName))) {
// Normalize is necessary for changing `\`s into `/`s on windows.
this.compile(path.normalize(fileName),
path.normalize(this.inputPaths[0]),
path.normalize(this.outputPath));
}
});
}

Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,33 @@ describe('Basic end-to-end Workflow', function () {
let componentPath = path.join(process.cwd(), 'src', 'app', 'test-component');
let cssFile = path.join(componentPath, 'test-component.component.css');
let scssFile = path.join(componentPath, 'test-component.component.scss');
let scssPartialFile = path.join(componentPath, '_test-component.component.partial.scss');

let scssPartialExample = '.partial {\n @extend .outer;\n }';
fs.writeFileSync(scssPartialFile, scssPartialExample, 'utf8');
expect(existsSync(scssPartialFile)).to.be.equal(true);

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

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

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

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

0 comments on commit af9a4f9

Please sign in to comment.