无法从scss加载css样式到视图

时间:2017-08-04 06:02:12

标签: css angularjs gulp

我无法加载样式来从scss查看,下面是gulp.js,

//编译并自动添加样式表

gulp.task('styles', function () {

     return gulp.src([
    'Content/styles/**/*.scss',
    'Content/styles/**/*.css'
  ])
    .pipe($.newer('Content/styles'))
    //.pipe($.newer('.tmp/styles'))
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      precision: 10
    }).on('error', $.sass.logError))
    .pipe($.autoprefixer({ browsers: AUTOPREFIXER_BROWSERS }))
    .pipe(gulp.dest('Content/styles'))
    //.pipe(gulp.dest('.tmp/styles'))
    // Concatenate And Minify Styles
    .pipe($.if('*.css', $.cssnano()))
    .pipe($.size({ title: 'styles' }))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest('Content'));
});

1 个答案:

答案 0 :(得分:0)

假设Content是您的目录,您可以使用相对路径,如: -

gulp.task('styles', function () {

     return gulp.src([
    './Content/styles/**/*.scss',
    './Content/styles/**/*.css'
  ])
    .pipe($.newer('./Content/styles'))
    //.pipe($.newer('.tmp/styles'))
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      precision: 10
    }).on('error', $.sass.logError))
    .pipe($.autoprefixer({ browsers: AUTOPREFIXER_BROWSERS }))
    .pipe(gulp.dest('./Content/styles'))
    //.pipe(gulp.dest('.tmp/styles'))
    // Concatenate And Minify Styles
    .pipe($.if('*.css', $.cssnano()))
    .pipe($.size({ title: 'styles' }))
    .pipe($.sourcemaps.write('./'))
    .pipe(gulp.dest('./Content'));
});