I am using Ionic framework for my html5 mobile app.
I know I can add custom sass into the ionic.app.scss file under the scss folder and ionic serve or ionic build will pile my sass into css, but if I want to add additional sass files here, for instance ionic.home.scss how do I get these to pile? Do I need to modify the gulp file.
I am basically extending the default Ionic tabs app app. Here is the structure I was wanting, basically a sass file for each template
+-- _gulpfile.js
+-- _scss
| +-- ionic.app.scss
| +-- tab-home.scss
| +-- tab-projects.scss
| +-- tab-services.scss
+-- _templates
| +-- tab-home.html
| +-- tab-projects.html
| +-- tab-services.html
+-- index.html
Here is the gulp file
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var paths = {
sass: ['./scss/**/*.scss']
};
gulp.task('default', ['sass']);
gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
.pipe(sass())
.pipe(gulp.dest('./www/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
.on('end', done);
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
});
gulp.task('install', ['git-check'], function() {
return bowermands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function(done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
}
done();
});
I am using Ionic framework for my html5 mobile app.
I know I can add custom sass into the ionic.app.scss file under the scss folder and ionic serve or ionic build will pile my sass into css, but if I want to add additional sass files here, for instance ionic.home.scss how do I get these to pile? Do I need to modify the gulp file.
I am basically extending the default Ionic tabs app app. Here is the structure I was wanting, basically a sass file for each template
+-- _gulpfile.js
+-- _scss
| +-- ionic.app.scss
| +-- tab-home.scss
| +-- tab-projects.scss
| +-- tab-services.scss
+-- _templates
| +-- tab-home.html
| +-- tab-projects.html
| +-- tab-services.html
+-- index.html
Here is the gulp file
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var paths = {
sass: ['./scss/**/*.scss']
};
gulp.task('default', ['sass']);
gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
.pipe(sass())
.pipe(gulp.dest('./www/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
.on('end', done);
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
});
gulp.task('install', ['git-check'], function() {
return bower.mands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function(done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('http://git-scm./downloads') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
}
done();
});
Share
Improve this question
edited Nov 19, 2014 at 2:35
svnm
asked Nov 19, 2014 at 2:04
svnmsvnm
24.4k23 gold badges94 silver badges109 bronze badges
2 Answers
Reset to default 9You can have just one ionic.app.scss
and extend it with @import
in this file.
@import "tab-home.scss", "tab-projects.scss", "tab-services.scss";
Change the gulp.src()
in the sass or scss task in your gulp file to something like gulp.src("_scss/**/*.scss")
the double * means that any subdirectories are included. Also if you dont want to output another css file you need to create partials(just add a _
to the beginning of your sass file names.