Programmatically launching the Compass Grunt task

I have a compass task running on grunt that creates a compiled base.css file , as well as a number of special CSS files. base.scss @imports _settings.scss partial, which dictates some global configuration for all files.

compass: {
    theme: {
        options: {
            sassDir: '/sass',
            cssDir: 'css',
            fontsPath: 'css/fonts',
            imagesPath: 'img'

        }
    }
}

I want to be able to call the compass task several times, but each time indicate that another settings file is being imported into base.scss, and another cssDir is used for output . Is it possible?

I tried to use the approach below, with a substantial addition to compasses config.rb (via raw) in two different compass tasks. Each task includes a different import path to the directory containing the settings file. This settings file is then selected as @import settings.scss at the top of my base.scss.

compass: {
    theme: {
        options: {
            httpPath: '/',
            sassDir: '/sass',
            cssDir: 'css',
            raw: 'add_import_path  "/sass/theme"'

        }
    },
    theme2: {
        options: {
            httpPath: '/',
            sassDir: '/sass',
            cssDir: 'css',
            raw: 'add_import_path  "/sass/theme2"'

        }
    }
}

It seems to work, and although it seems to hack it, I am closest to a working solution. There seems to be a way to do this, but so far the solution has alluded to me.

Now I'm wondering if I can use registerTask () to create the functionality I need in the approach, for example, the one I found here:

Programmatically pass arguments to a grunt job?

+4
1

, , , , . , .

shared/
  _partial1.scss
  _partial2.scss
  _partial3.scss
  _partial4.scss
  _partial5.scss
  _base.scss
theme1.scss
theme2.scss

, , #.scss. , , "base.css", grunt, https://github.com/gruntjs/grunt-contrib-copy, #.css # base.css.

1.scss :

$variable1: '';
$variable2: '';
$variable3: '';

@import 'base',
        'partial1',
        'partial2',
        'partial3',
        'partial4',
        'partial5';
+1

Source: https://habr.com/ru/post/1539007/


All Articles