Grunt remove unused CSS recursively

310 Views Asked by At

I have a project which has multiple directories in which css is stored (slightly different css for different languages)

Example Directory Structure:

/sass

 - /latin
 - /hindi
 - /chinese

Inside each of those directories is an index.scss file.

I then have a mustache template which pulls in css from the correct directory based on the language set.

I have tried using purify css and unCSS they both work great with a single .css file but do not seem to work when you have multiple directories and files.

I would like each file in each directory to have the unused css removed and a new file created in each directory.

Now grunt supports this sort of recursive task using this format for a task:

files: [
    {
      expand: true,     // Enable dynamic expansion.
      cwd: 'lib/',      // Src matches are relative to this path.
      src: ['**/*.js'], // Actual pattern(s) to match.
      dest: 'build/',   // Destination path prefix.
      ext: '.min.js',   // Dest filepaths will have this extension.
      extDot: 'first'   // Extensions in filenames begin after the first dot
    },

But it seems that the two unused css tasks I have tried do not support this.

Does anyone have any suggestions?

Thanks.

0

There are 0 best solutions below