【问题标题】:grunt compass give single scss filegrunt compass 提供单个 scss 文件
【发布时间】:2017-12-08 16:20:41
【问题描述】:

我正在使用 grunt compass,我只想编译单个 scss 文件 src/scss/image_slider.scss 而不是 scss 文件夹下的所有文件。

以下编写的代码适用于完整的 scss 文件夹。

compass: {
        dist: {
            options: {
                sassDir: 'src/scss',
                cssDir: 'src/css',
            }
        }
    },

【问题讨论】:

    标签: sass gruntjs compass-sass compass grunt-contrib-compass


    【解决方案1】:

    grunt-contrib-compasshttps://github.com/gruntjs/grunt-contrib-compass#specify中有一个选项:

    specify
    
    Type: String|Array
    
    Lets you specify which files you want to compile. 
    Useful if you don't want to compile the whole folder. 
    Globbing supported. Ignores filenames starting with underscore. 
    Paths are relative to the Gruntfile.
    

    所以你应该能够:

    compass: {
        dist: {
            options: {
                sassDir: 'src/scss',
                cssDir: 'src/css',
                specify: 'myfile.scss'
            }
        }
    },
    

    【讨论】:

    • 出现以下错误:正在运行“compass:dist”(罗盘)任务specify 选项使用,但未找到文件。警告:binaryversionRange 需要使用 --force 继续。
    • 它告诉你找不到指定的文件:specify option used, but no files were found,确保文件在预期的位置
    • 是的,我确实知道,并且文件存在于指定位置。
    • 如果我给出 sassDir 然后它会编译那个 sass 文件,但是当我给出相同的文件名时指定它告诉没有找到文件
    【解决方案2】:

    它以以下格式工作:

    compass: {
            dist: {
                options: {
                    sassDir: 'src/scss',
                    specify: 'src/scss/my_file.scss',
                    cssDir: 'src/css',
                }
            }
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-01
      • 2012-09-07
      • 2012-10-18
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 1970-01-01
      • 2014-06-13
      相关资源
      最近更新 更多