Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic create new sass file

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 compile 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 compile? 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.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();
});
like image 244
svnm Avatar asked Jan 09 '23 10:01

svnm


1 Answers

You 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";
like image 182
Kate Miháliková Avatar answered Jan 16 '23 23:01

Kate Miháliková