【问题标题】:Compass in not compiling sass to css指南针不将 sass 编译为 css
【发布时间】:2018-08-17 12:58:53
【问题描述】:

运行 gulp sass 文件后不会编译成 CSS。我检查了目录,一切看起来都很好。没有错误,gulp 正在运行,就好像 src/styles 目录中没有 .SASS 文件一样。 dist/css 文件夹中没有生成任何内容。任何帮助,将不胜感激。谢谢 这是 gulpfile.js

var gulp = require('gulp'),
    compass = require('gulp-compass');

gulp.task('compass', function () {
    return gulp.src('src/styles/main.sass')
        .pipe(compass({
            sass: 'src/styles',
            image: 'src/images',
            css: 'dist/css',
            generated_images_path: 'dist/images',
            sourcemap: true,
            style: 'compressed'
        }))
        .on('error', function(err) {
            console.log(err);
        });
});


gulp.task('default', function () {
    gulp.watch('./src/styles/**/*.sass', ['compass']);
    gulp.watch('./src/images/**/*', ['compass']);
});

my directory structure

root
 | 
 |
 +-- src
 |    |  
 |    +-- styles/sass
 |    +-- images
 | 
 +-- dist
      |  
      +-- css
      +-- images

【问题讨论】:

  • 嗨,我会把你的第二行改成“var sass = require('gulp-sass');”不是 var sass = require('gulp-compass')。您需要将 compass 导入到您的 sass 中,然后编译所有 sass。我不认为只编译指南针会给你任何输出。更多信息请看这里:ryanchristiani.com/getting-started-with-gulp-and-sass
  • 它不工作。它会引发错误。
  • 请发布错误。看看我发布的那篇文章,确保你的代码是相似的。
  • 这里是错误截图的链接。 imgur.com/KqiVzZO
  • 在确保所有代码和目录结构就位后出现另一个错误:imgur.com/a/fXpl8

标签: css sass gulp compass


【解决方案1】:

通过将 compass 和 sass 安装为 ruby​​ gem 并将 ruby​​ 路径添加到环境变量中解决了这个问题。

【讨论】:

    猜你喜欢
    • 2013-12-29
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    相关资源
    最近更新 更多