purifycss / grunt-purifycss

Remove unused CSS with the grunt build tool
MIT License
163 stars 21 forks source link

bug(newer): PurifyCSS doesn't work with grunt-newer #30

Open Kristinita opened 6 years ago

Kristinita commented 6 years ago

1. Summary

PurifyCSS doesn't work with grunt-newer for me. I get in terminal:

Warning: Cannot read property 'forEach' of undefined Use --force to continue.

Aborted due to warnings.

Many another Grunt plugins successful works with grunt-newer for me.

2. Environment

3. Configuration

See example configuration in SashaGruntDebugging branch of my demo repository.

Gruntfile.coffee:

module.exports = (grunt) ->

    require('load-grunt-tasks')(grunt)

    grunt.initConfig

        purifycss:
            sashapurify:
                src: ['SashaPurify.html']
                css: ['SashaPurify.css']
                dest: 'SashaPurify.css'

SashaPurify.css:

.SashaClass {
    color: red;
}

.SashaUnusedClass {
    color: green;
}

SashaPurify.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div class="SashaClass">Sasha text</div>
</body>
</html>

4. Steps to reproduce

I run in terminal:

  1. grunt purifycss --verbose,

or

  1. grunt newer:purifycss --verbose.

5. grunt purifycss behavior

Good.

D:\SashaDemoRepositories\SashaGruntDebugging>grunt purifycss --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.coffee" Gruntfile…OK

Registering Gruntfile tasks.

Registering "grunt-newer" local Npm module tasks.
Reading D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-newer\package.json…OK
Parsing D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-newer\package.json…OK
Loading "newer.js" tasks…OK
+ any-newer, newer, newer-clean, newer-postrun

Registering "grunt-purifycss" local Npm module tasks.
Reading D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-purifycss\package.json…OK                                         4:44 PMParsing D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-purifycss\package.json…OK
Loading "purifycss.js" tasks…OK
+ purifycss
Initializing config…OK
Loading "Gruntfile.coffee" tasks…OK
>> No tasks were registered or unregistered.

Running tasks: purifycss

Running "purifycss" task

Running "purifycss:sashapurify" (purifycss) task
Verifying property purifycss.sashapurify exists in config…OK
Files: SashaPurify.html -> SashaPurify.css
Options: write=false, info
Source Files:  [ 'SashaPurify.html' ]
Style Files:  [ 'SashaPurify.css' ]

    ________________________________________________
    |
    |   PurifyCSS has reduced the file size by ~ 57.7%
    |
    ________________________________________________

Writing SashaPurify.css…OK
File "SashaPurify.css" created.

Done.

6. grunt newer:purifycss behavior

Bug.

D:\SashaDemoRepositories\SashaGruntDebugging>grunt newer:purifycss --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.coffee" Gruntfile…OK

Registering Gruntfile tasks.

Registering "grunt-newer" local Npm module tasks.
Reading D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-newer\package.json…OK
Parsing D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-newer\package.json…OK
Loading "newer.js" tasks…OK
+ any-newer, newer, newer-clean, newer-postrun

Registering "grunt-purifycss" local Npm module tasks.
Reading D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-purifycss\package.json…OK
Parsing D:\SashaDemoRepositories\SashaGruntDebugging\node_modules\grunt-purifycss\package.json…OK
Loading "purifycss.js" tasks…OK
+ purifycss
Initializing config…OK
Loading "Gruntfile.coffee" tasks…OK
>> No tasks were registered or unregistered.

Running tasks: newer:purifycss

Running "newer:purifycss" (newer) task

Running "newer:purifycss:sashapurify" (newer) task
Options: cache="D:\\SashaDemoRepositories\\SashaGruntDebugging\\node_modules\\grunt-newer\\.cache", override=undefined, tolerance=0
Files: SashaPurify.html -> SashaPurify.css

Running "purifycss:sashapurify" (purifycss) task
Verifying property purifycss.sashapurify exists in config…OK
Files: SashaPurify.html -> SashaPurify.css
Options: write=false, info
Warning: Cannot read property 'forEach' of undefined Use --force to continue.

Aborted due to warnings.

7. Not helped

I read grunt-newer description → I don't find errors in my configuration.

Thanks.