Ionic create new sass file

I am using Ionic framework for my html5 mobile app.

I know I can add custom sass to ionic.app.scss file under scss folder and ionic feed or ionic build will compile my sass to css, but if I want to add additional sass files here like ionic. home.scss how can I build them? I need to modify the gulp.

I am basically extending the standard Ionic tabs app . Here is the structure I wanted, 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.commands.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.com/downloads') + '.',
      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
    );
    process.exit(1);
  }
  done();
});

      

+3


source to share


2 answers


You can only have one ionic.app.scss

and extend it with @import

in this file.



@import "tab-home.scss", "tab-projects.scss", "tab-services.scss";

      

+9


source


Change gulp.src()

in the sass or scss task in your gulp file to something like gulp.src("_scss/**/*.scss")

. double * means all subdirectories are included. Also, if you don't want to output another css file, you need to create partial (just add _

to the beginning of your sass file names.



0


source







All Articles