gruntjs / grunt-contrib-compass

Compile Compass to CSS.
http://gruntjs.com/
MIT License
626 stars 128 forks source link

Grunt contrib compass is giving error - Individual stylesheets must be in the sass directory #254

Open debo07 opened 8 years ago

debo07 commented 8 years ago

I have multiple sass files inside my assetsdirectory. I want to compile a different sass files for different target. I have used specifyoption but still it's showing the error that - 'Individual stylesheets must be in the sass directory'. Below is my grunt task for compass.

compass: {
  options: {
        sassDir: './src/assets',
        cssDir: '<%= build_dir %>/assets/',
        generatedImagesDir: '<%= build_dir %>/assets/images/generated',
        imagesDir: './src/assets/images',
        javascriptsDir: './src/scripts',
        fontsDir: './src/assets/fonts',
        importPath: './vendor',
        httpImagesPath: 'images',
        httpGeneratedImagesPath: 'images/generated',
        httpFontsPath: '<%= build_dir %>/assets/fonts',
        relativeAssets: false,
        assetCacheBuster: false,
        raw: 'Sass::Script::Number.precision = 10\n',
    },
    buildA: { // Target
        options: {
            outputStyle: 'expanded',
            specify: ['./src/assets/appA.scss']
        }
    },
    buildB: { // Target
        options: {
            outputStyle: 'expanded',
            specify: ['./src/assets/appB.scss']
        }
    }
}

What I want to achieve is when I execute grunt compass:buildA, it should compile only appA.scss file not appB.scss. And similarly for grunt compass:buildB it should only compile appB.scss. I hope you can figure out the directory structure.

alexander-nitsche commented 7 years ago

The problem is the check of the ruby gem compass if the files of buildA.options.specify and buildB.options.specify lie within the sassDir. This check compares the absolute paths of the files with the sassPath (projectPath/sassDir) and expects the sassPath to be the beginning of the file paths. The problem is that the sassPath is not properly constructed for sassDir containing dots.

This should help:

var path = require('path');
..
grunt.initConfig({
..
compass: {
  options: {
        sassDir: path.resolve('./src/assets'),
        ..
numediaweb commented 3 years ago

Thanks @alexander-nitsche this resolved this issue for me :)