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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)