Skip to content

Commit f08c343

Browse files
committed
Merge pull request #2 from ajoslin/master
add Sass as style choice
2 parents 0dfdd1f + ab9da1b commit f08c343

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ You will now be prompted to give your new AngularJS app a name, which will be da
3737

3838
### CSS Preprocessor
3939

40-
You can choose between `LESS` and `Stylus` to use as the CSS Preprocessor for your project.
40+
You can choose between `LESS`, `Stylus`, and `Sass` to use as the CSS Preprocessor for your project.
4141

42-
*Note* All `_*.styl` or `_*.less` files will be considered "partials" and must be imported in another stylesheet file (without a leading "_") to be compiled.
42+
*Note* All `_*.styl`, `_*.less`, or `_*.scss` files will be considered "partials" and must be imported in another stylesheet file (without a leading "_") to be compiled.
4343

4444
### Project structure
4545

@@ -62,18 +62,18 @@ my-angular-app/
6262
└── src
6363
└── app
6464
├── app.js # Main app module and configuration
65-
├── app.styl or app.less # Main app stylesheet
65+
├── app.styl/less/scss # Main app stylesheet
6666
├── index.html # The index.html / app layout template
6767
├── assets # A folder meant for images and such...
6868
│   └── .gitkeep
6969
├── styles
70-
│   └── _base.styl or _base.less # A stylesheet partial with base styles
70+
│   └── _base.styl/less/scss # A stylesheet partial with base styles
7171
└── todo
7272
├── todo-controller.js # The todo controller
7373
├── todo-controller_test.js # Karma test for the todo controller
7474
├── todo.html # The todo list template
7575
├── todo.js # The todo module
76-
└── todo.styl or todo.less # Todo module specific styles
76+
└── todo.styl/less/scss # Todo module specific styles
7777
```
7878

7979
### Gulpfile

slushfile.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@ var gulp = require('gulp'),
66
inquirer = require('inquirer'),
77
_ = require('underscore.string');
88

9+
var cssTypeData = {
10+
'less': {
11+
plugin: 'gulp-less',
12+
pluginVersion: '^1.2.3',
13+
pipeCommand: 'g.less()',
14+
extension: 'less'
15+
},
16+
'sass': {
17+
plugin: 'gulp-sass',
18+
pluginVersion: '^0.7.1',
19+
pipeCommand: 'g.sass()',
20+
extension: 'scss'
21+
},
22+
'styl': {
23+
plugin: 'gulp-stylus',
24+
pluginVersion: '^0.1.0',
25+
pipeCommand: 'g.stylus({ use: ["nib"] })',
26+
extension: 'styl'
27+
}
28+
};
29+
930
gulp.task('default', function (done) {
1031
inquirer.prompt([
1132
{type: 'input', name: 'name', message: 'What do you want to name your AngularJS app?', default: getNameProposal()},
12-
{type: 'list', name: 'csstype', message: 'What CSS preprocessor do you want to use?', default: 'styl', choices: [{name: 'Stylus', value: 'styl'}, {name: 'LESS', value: 'less'}]},
33+
{type: 'list', name: 'csstype', message: 'What CSS preprocessor do you want to use?', default: 'styl', choices: [
34+
{name: 'Stylus', value: 'styl'},
35+
{name: 'LESS', value: 'less'},
36+
{name: 'Sass', value: 'sass'}
37+
]},
1338
{type: 'confirm', name: 'example', message: 'Do you want to include a Todo List example in your app?', default: true}
1439
],
1540
function (answers) {
@@ -19,11 +44,13 @@ gulp.task('default', function (done) {
1944
if (!answers.example) {
2045
files.push('!' + __dirname + '/templates/src/app/todo/**');
2146
}
47+
answers.styleData = cssTypeData[answers.csstype];
48+
console.log(answers.styleData, answers.csstype);
2249
return gulp.src(files)
2350
.pipe(template(answers))
2451
.pipe(rename(function (file) {
2552
if (file.extname === '.css') {
26-
file.extname = '.' + answers.csstype;
53+
file.extname = '.' + answers.styleData.extension;
2754
} else if (file.basename[0] === '_') {
2855
file.basename = '.' + file.basename.slice(1);
2956
}

templates/gulpfile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ gulp.task('clean-css', function () {
4141

4242
gulp.task('styles', ['clean-css'], function () {
4343
return gulp.src([
44-
'./src/app/**/*.<%= csstype %>',
45-
'!./src/app/**/_*.<%= csstype %>'
44+
'./src/app/**/*.<%= styleData.extension %>',
45+
'!./src/app/**/_*.<%= styleData.extension %>'
4646
])
47-
<% if (csstype === 'styl') { %>.pipe(g.stylus({use: ['nib']}))<% } else { %>.pipe(g.less())<% } %>
47+
.pipe(<%= styleData.pipeCommand %>)
4848
.pipe(gulp.dest('./.tmp/css/'))
4949
.pipe(g.cached('built-css'))
5050
.pipe(livereload());
@@ -146,7 +146,7 @@ gulp.task('watch', ['statics', 'default'], function () {
146146
});
147147
gulp.watch('./src/app/index.html', ['index']);
148148
gulp.watch(['./src/app/**/*.html', '!./src/app/index.html'], ['templates']);
149-
gulp.watch(['./src/app/**/*.<%= csstype %>'], ['csslint']).on('change', function (evt) {
149+
gulp.watch(['./src/app/**/*.<%= styleData.extension %>'], ['csslint']).on('change', function (evt) {
150150
if (evt.type !== 'changed') {
151151
gulp.start('index');
152152
}

templates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"gulp-serve": "~0.1.1",
3232
"gulp-concat": "~2.1.7",
3333
"gulp-clean": "~0.2.4",
34-
<% if (csstype === 'styl') { %>"gulp-stylus": "~0.1.0"<% } else { %>"gulp-less": "1.2.3"<% } %>,
34+
"<%= styleData.plugin %>": "<%= styleData.pluginVersion %>",
3535
"gulp-minify-css": "~0.3.0",
3636
"gulp-csslint": "~0.1.3",
3737
"event-stream": "~3.1.0",

0 commit comments

Comments
 (0)