2016-04-25 6 views
0

Source link sind - ich weiß nicht, was hierschluck-json-Sass - Kann nicht JSON-Datei

Alles in Ordnung, wenn ich Datei bin nicht mit json

1) gulpfile.js

fehlt
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 Datei

.test{ 
    color:$color; 
} 

4) Fehlermeldung enter image description here

+0

Veröffentlichen Sie keine Screenshots von Code oder Fehlern. – cimmanon

+0

Warum irgendein Problem hier? – ShibinRagh

+0

http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question – cimmanon

Antwort

1

1. Sie ausgeben SCSS wollen, nicht SASS. Das bedeutet, dass Ihre sass Option für gulp-json-sass falsch ist. Von der docs:

Wenn truthy, Ausgabe gültig Sass Variablen. Wenn false, geben Sie scss-Variablen aus.

2. Sie können nicht gulp-ruby-sass in einem Rohr verwenden. Vom docs:

Verwenden gulp-ruby-sass statt gulp.src zu Sass-Dateien zu kompilieren.

Das bedeutet .pipe(sass()) wird nicht funktionieren. Sie müssen gulp-sass statt gulp-ruby-sass verwenden.

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/')); 
}); 
+0

Awesome ... arbeitete – ShibinRagh

+0

Do Sie irgendein, wie man "-" Problem löst, wenn Sie Kind json schreiben? https://www.npmjs.com/package/gulp-json-sass – ShibinRagh

+0

Keine Ahnung, was du meinst. Erstellen Sie eine neue Frage und geben Sie eine detailliertere Beschreibung Ihres Problems. –