Skip to content

Commit bc755e6

Browse files
committed
docs: css preprocessors support
1 parent ef5ae91 commit bc755e6

6 files changed

+32
-36
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The generated project has dependencies that require **Node 4 or greater**.
3333
* [Deploying the App via GitHub Pages](#deploying-the-app-via-github-pages)
3434
* [Support for offline applications](#support-for-offline-applications)
3535
* [Commands autocompletion](#commands-autocompletion)
36+
* [CSS preprocessor integration](#css-preprocessor-integration)
3637
* [Known Issues](#known-issues)
3738

3839
## Installation
@@ -249,6 +250,18 @@ ng completion >> ~/.bash_profile
249250
source ~/.bash_profile
250251
```
251252

253+
254+
### CSS Preprocessor integration
255+
256+
We support all major CSS preprocessors:
257+
- sass (node-sass)
258+
- less (less)
259+
- compass (compass-importer + node-sass)
260+
- stylus (stylus)
261+
262+
To use one just install for example `npm install node-sass` and rename `.css` files in your project to `.scss` or `.sass`. They will be compiled automatically.
263+
264+
252265
## Known issues
253266

254267
This project is currently a prototype so there are many known issues. Just to mention a few:

lib/broccoli/angular-broccoli-compass.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,22 @@ try {
3737
}
3838

3939
build() {
40-
let entries = this.listEntries();
41-
let rootFileNames = entries.map(e => {
42-
return path.resolve(e.basePath, e.relativePath);
43-
});
44-
45-
rootFileNames.forEach(fileName => {
40+
this.listEntries().forEach(e => {
41+
let fileName = path.resolve(e.basePath, e.relativePath);
4642
this.compile(fileName, this.inputPaths[0], this.outputPath);
4743
});
4844
}
4945

5046
compile(fileName, inputPath, outputPath) {
5147
let sassOptions = {
52-
file: path.join(fileName),
48+
file: path.normalize(fileName),
5349
includePaths: this.inputPaths,
5450
data: '@import "compass"; .transition { @include transition(all); }',
5551
importer: compass
5652
};
5753

5854
let result = sass.renderSync(sassOptions);
59-
let filePath = fileName.replace(inputPath, outputPath)
60-
.replace(/\.scss$/, '.css')
61-
.replace(/\.sass$/, '.css');
55+
let filePath = fileName.replace(inputPath, outputPath).replace(/\.s[ac]ss$/, '.css');
6256

6357
fse.outputFileSync(filePath, result.css, 'utf8');
6458
}

lib/broccoli/angular-broccoli-less.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ try {
3333
}
3434

3535
build() {
36-
let entries = this.listEntries();
37-
let rootFileNames = entries.map(e => {
38-
return path.resolve(e.basePath, e.relativePath);
39-
});
40-
41-
return Promise.all(rootFileNames.map(fileName => {
36+
return Promise.all(this.listEntries().map(e => {
37+
let fileName = path.resolve(e.basePath, e.relativePath);
4238
return this.compile(fileName, this.inputPaths[0], this.outputPath);
4339
}));
4440
}

lib/broccoli/angular-broccoli-sass.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ try {
3232
}
3333

3434
build() {
35-
let entries = this.listEntries();
36-
let rootFileNames = entries.map(e => {
37-
return path.resolve(e.basePath, e.relativePath);
38-
});
39-
40-
rootFileNames.forEach(fileName => {
35+
this.listEntries().forEach(e => {
36+
let fileName = path.resolve(e.basePath, e.relativePath);
4137
this.compile(fileName, this.inputPaths[0], this.outputPath);
4238
});
4339
}
@@ -49,9 +45,7 @@ try {
4945
};
5046

5147
let result = sass.renderSync(sassOptions);
52-
let filePath = fileName.replace(inputPath, outputPath)
53-
.replace(/\.scss$/, '.css')
54-
.replace(/\.sass$/, '.css');
48+
let filePath = fileName.replace(inputPath, outputPath).replace(/\.s[ac]ss$/, '.css');
5549

5650
fse.outputFileSync(filePath, result.css, 'utf8');
5751
}

lib/broccoli/angular-broccoli-stylus.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ try {
3333
}
3434

3535
build() {
36-
let entries = this.listEntries();
37-
let rootFileNames = entries.map(e => {
38-
return path.resolve(e.basePath, e.relativePath);
39-
});
40-
41-
return Promise.all(rootFileNames.map(fileName => {
36+
return Promise.all(this.listEntries().map(e => {
37+
let fileName = path.resolve(e.basePath, e.relativePath);
4238
return this.compile(fileName, this.inputPaths[0], this.outputPath);
4339
}));
4440
}

tests/e2e/e2e_workflow.spec.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ describe('Basic end-to-end Workflow', function () {
220220
it('Uninstalls sass support successfully via `ng uninstall sass`', function(done) {
221221
this.timeout(420000);
222222

223-
sh.exec('npm uninstall node-sass', { silent: true });
224223
let sassPath = path.join(process.cwd(), 'node_modules', 'node-sass');
224+
expect(existsSync(sassPath)).to.be.equal(true);
225+
sh.exec('npm uninstall node-sass', { silent: true });
225226
expect(existsSync(sassPath)).to.be.equal(false);
226227
return ng(['destroy', 'component', 'test-component'])
227228
.then(() => {
@@ -257,9 +258,10 @@ describe('Basic end-to-end Workflow', function () {
257258

258259
it('Uninstalls less support successfully via `ng uninstall less`', function() {
259260
this.timeout(420000);
260-
261-
sh.exec('npm uninstall less', { silent: true });
261+
262262
let lessPath = path.join(process.cwd(), 'node_modules', 'less');
263+
expect(existsSync(lessPath)).to.be.equal(true);
264+
sh.exec('npm uninstall less', { silent: true });
263265
expect(existsSync(lessPath)).to.be.equal(false);
264266
return ng(['destroy', 'component', 'test-component'])
265267
.then(() => {
@@ -293,9 +295,10 @@ describe('Basic end-to-end Workflow', function () {
293295

294296
it('Uninstalls stylus support successfully via `ng uninstall stylus`', function() {
295297
this.timeout(420000);
296-
297-
sh.exec('npm uninstall stylus', { silent: true });
298+
298299
let stylusPath = path.join(process.cwd(), 'node_modules', 'stylus');
300+
expect(existsSync(stylusPath)).to.be.equal(true);
301+
sh.exec('npm uninstall stylus', { silent: true });
299302
expect(existsSync(stylusPath)).to.be.equal(false);
300303
return ng(['destroy', 'component', 'test-component'])
301304
.then(() => {

0 commit comments

Comments
 (0)