dongmei3869 2019-01-14 05:32
浏览 123

CSS路径不在gulp和下划线之间对齐

I am creating a WordPress site but the CSS is not showing up. I think I have narrowed it down to the pathing not being correct. but whenever I try to fix up the pathing gulp creates a new CSS output. I am using underscores sassified and gulp sass which I don't think are metting the same path. I can get underscores get_stylesheet_uri to use a CSS file that successfully outputs styling on my page. but I can't get the path correct on my gulpfile to output to the same CSS file

var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var cssnano = require('gulp-cssnano');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
var del = require('del');
var runSequence = require('run-sequence');

// Basic Gulp task syntax
gulp.task('hello', function() {
  console.log('Hello Zell!');
})

// Development Tasks 
// -----------------

// Start browserSync server
gulp.task('browserSync', function() {
    browserSync.init({
      proxy: "localhost/sewintune"
  });
  });

  gulp.task('sass', function() {
    return gulp.src('app/sass/**/*.scss') // Gets all files ending with .scss in app/scss and children dirs
      .pipe(sass().on('error', sass.logError)) // Passes it through a gulp-sass, log errors to console
      .pipe(gulp.dest('../wp-content/themes/sew-in-tune/app/css/styles.css')) // Outputs it in the css folder
      .pipe(browserSync.reload({ // Reloading with Browser Sync
        stream: true
      }));
  })

// Watchers
gulp.task('watch', function() {
  gulp.watch('app/sass/**/*.scss', ['sass']);
  gulp.watch('app/*.php', browserSync.reload);
  gulp.watch('app/js/**/*.js', browserSync.reload);
})

// Optimization Tasks 
// ------------------

// Optimizing CSS and JavaScript 
gulp.task('useref', function() {

  return gulp.src('app/*.php')
    .pipe(useref())
    .pipe(gulpIf('*.js', uglify()))
    .pipe(gulpIf('*.css', cssnano()))
    .pipe(gulp.dest('dist'));
});

// Optimizing Images 
gulp.task('images', function() {
  return gulp.src('app/images/**/*.+(png|jpg|jpeg|gif|svg)')
    // Caching images that ran through imagemin
    .pipe(cache(imagemin({
      interlaced: true,
    })))
    .pipe(gulp.dest('dist/images'))
});

// Copying fonts 
gulp.task('fonts', function() {
  return gulp.src('app/fonts/**/*')
    .pipe(gulp.dest('dist/fonts'))
})

// Cleaning 
gulp.task('clean', function() {
  return del.sync('dist').then(function(cb) {
    return cache.clearAll(cb);
  });
})

gulp.task('clean:dist', function() {
  return del.sync(['dist/**/*', '!dist/images', '!dist/images/**/*']);
});

// Build Sequences
// ---------------

gulp.task('default', function(callback) {
  runSequence(['sass', 'browserSync'], 'watch',
    callback
  )
})
  • 写回答

1条回答 默认 最新

  • douji1058 2019-01-14 07:34
    关注

    This line is incorrect:

    .pipe(gulp.dest('../wp-content/themes/sew-in-tune/app/css/styles.css')) // Outputs it in the css folder
    

    gulp.dest takes a folderName not a filename. You code is probably creating a folder actually called styles.css.

    Your gulp.src for a 'sass' task is typically a single file, like 'styles.scss', which imports your partials into it. [Not the only way to do it.] So that task might look like this:

    gulp.task('sass', function() {
        return gulp.src('app/sass/**/styles.scss') 
          .pipe(sass().on('error', sass.logError))
    
          // with no other modification, the below is the directory linked to in your html + styles.css 
    
          .pipe(gulp.dest('../wp-content/themes/sew-in-tune/app/css')) 
          .pipe(browserSync.reload({ 
            stream: true
          }));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示