2016-12-06 91 views
0

對於我的測試Web應用程序使用我6.基金會,但我不明白我一飲而盡配置文件如何正確配置ASP.NET Core + Foundation 6如何正確配置gulp配置文件?

發現這個例子gulpfile

var gulp = require('gulp'); 
var $ = require('gulp-load-plugins')(); 

var sassPaths = [ 
    'lib/foundation-sites/scss', 
    'lib/motion-ui/src', 
    '../../lib/scss' 
]; 

gulp.task('sass', function() { 
    return gulp.src('../../lib/scss/app.scss') 
     .pipe($.sass({ 
      includePaths: sassPaths 
     }) 
     .on('error', $.sass.logError)) 
     .pipe($.autoprefixer({ 
      browsers: ['last 2 versions', 'ie >= 9'] 
     })) 
     .pipe(gulp.dest('../../inc/css')); 
}); 

gulp.task('default', ['sass'], function() { 
    gulp.watch(['../../lib/scss/**/*.scss'], ['sass']); 
}); 

但他不工作。而我的理解會很少,還需要js

回答

1

這裏是我的gulpfile.js的內容。請參閱「sass」任務。

/// <binding Clean='clean' /> 
"use strict"; 

var gulp = require("gulp"), 
    rimraf = require("rimraf"), 
    concat = require("gulp-concat"), 
    cssmin = require("gulp-cssmin"), 
    uglify = require("gulp-uglify"), 
    sass = require("gulp-sass"), 
    debug = require("gulp-debug"); 

    //sass = require("gulp-sass"), 
    //debug = require('gulp-debug'), 
//mainBowerFiles = require('main-bower-files'); 
//* see https://github.com/mauricedb/gulp-main-bower-files if decide to concat libs into one **// 
//http://stackoverflow.com/questions/32783158/why-are-bower-components-installed-in-wwwroot/32790748#32790748 

var webroot = "./wwwroot/"; 

var paths = { 
    js: webroot + "js/**/*.js", 
    minJs: webroot + "js/**/*.min.js", 
    css: webroot + "css/**/*.css", 
    minCss: webroot + "css/**/*.min.css", 
    concatJsDest: webroot + "js/site.min.js", 
    concatCssDest: webroot + "css/site.min.css" 
}; 

gulp.task("clean:js", function (cb) { 
    rimraf(paths.concatJsDest, cb); 
}); 

gulp.task("clean:css", function (cb) { 
    rimraf(paths.concatCssDest, cb); 
}); 

gulp.task("clean", ["clean:js", "clean:css"]); 

gulp.task("min:js", function() { 
    return gulp.src([paths.js, "!" + paths.minJs], { base: "." }) 
     .pipe(concat(paths.concatJsDest)) 
     .pipe(uglify()) 
     .pipe(gulp.dest(".")); 
}); 

gulp.task("min:css", function() { 
    return gulp.src([paths.css, "!" + paths.minCss]) 
     .pipe(concat(paths.concatCssDest)) 
     .pipe(cssmin()) 
     .pipe(gulp.dest(".")); 
}); 

gulp.task("min", ["min:js", "min:css"]); 

// where to find sass code 
paths.sassSource = webroot + "scss/**/*.scss"; 

// where to output compiled CSS code 
paths.cssOutput = webroot + "css/"; 

// where to find bower resources 
paths.bower_components = webroot + "lib/" 

gulp.task('sass', function() { 
    gulp.src(paths.sassSource) 
     .pipe(sass({ 
      includePaths: [ 
       paths.bower_components + 'foundation-sites/scss', 
       paths.bower_components + 'motion-ui/src' 
      ] 
     }).on('error', sass.logError)) 
     .pipe(debug()) 
     .pipe(gulp.dest(paths.cssOutput)); 
});