grunt compass 给出单个 scss 文件

grunt compass give single scss file

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

下面编写的代码适用于完整的 scss foler。

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

grunt-contrib-compass中有选项 https://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: {
            options: {
                sassDir: 'src/scss',
                specify: 'src/scss/my_file.scss',
                cssDir: 'src/css',
            }
        }
    },