0

Source link - I don't know what is missing here

Everything fine if I am not including json file

1) gulpfile.js

var jsonSass = require('gulp-json-sass'),
    gulp = require('gulp'),
    concat = require('gulp-concat'),
    sass = require('gulp-ruby-sass');


    gulp.task('sass', function() {
      return gulp
        .src(['sass/example.json', 'sass/example.scss'])
        .pipe(jsonSass({
          sass: true
        }))
        .pipe(concat('output.scss'))
        .pipe(sass())
        .pipe(gulp.dest('out/'));
});

gulp.task('default', ['sass']);

2) example.json

{
    "color": "blue"
}

3) example.scss file

.test{
    color:$color; 
}

4) error message enter image description here

Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70
ShibinRagh
  • 6,530
  • 4
  • 35
  • 57

1 Answers1

1

1. You want to output SCSS, not SASS. That means your sass option for gulp-json-sass is wrong. From the docs:

If truthy, output valid sass variables. If false, output scss variables.

2. You can't use gulp-ruby-sass in a pipe. From the docs:

Use gulp-ruby-sass instead of gulp.src to compile Sass files.

That means .pipe(sass()) won't work. You have to use gulp-sass instead of gulp-ruby-sass.

var jsonSass = require('gulp-json-sass'),
    gulp = require('gulp'),
    concat = require('gulp-concat'),
    sass = require('gulp-sass');

gulp.task('sass', function() {
  return gulp.src(['sass/example.json', 'sass/example.scss'])
    .pipe(jsonSass({
      sass: false 
    }))
    .pipe(concat('output.scss'))
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('out/'));
});
Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70
  • Do you any how to solve "-" issue when writing child json ? https://www.npmjs.com/package/gulp-json-sass – ShibinRagh Apr 25 '16 at 11:37
  • No idea what you mean. Create a new question and give a more detailed description of your problem. – Sven Schoenung Apr 25 '16 at 11:47
  • I was asking about json-sass options about "delim" https://www.npmjs.com/package/gulp-json-sass#jsonsassoptions , Is it big issue just leave it :) I will add it as another question – ShibinRagh Apr 25 '16 at 12:01