Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Code example error #1

Open
spointecker opened this issue Jan 31, 2018 · 10 comments
Open

Code example error #1

spointecker opened this issue Jan 31, 2018 · 10 comments

Comments

@spointecker
Copy link

spointecker commented Jan 31, 2018

Hi,

I just tried the plugin and recognized an error in the example you have given:
I had to add a "section" and wrap the files parameter, otherwise "files" was always empty.

grunt.initConfig({
  purgecss: {
    options: {
      content: ['src/**/*.html'],
    },
    app: {
        files: {
          'dist/main.css': ['src/**/*.css'],
        },
    }
  },
});

In addition to this, there is no file written in my case. It just stops during the purge process.

     grunt.log.writeln('1');

      // purgecss
      var purgecssResult = new Purgecss({
        content: options.content,
        css: f.src
      }).purge()[0].css
      grunt.log.writeln('2');

So "1" will be printed but "2" doesn´t.


Running "purgecss:app" (purgecss) task
Verifying property purgecss.app exists in config...OK
Files: #mypath#mycss.css -> #mypath#mycss.min.css
Options: content=["#mypath#/**/*.twig"]
1

Done.
@spointecker
Copy link
Author

@Ffloriel ping

@Ffloriel
Copy link
Member

Thanks for reporting the issue. Fixing the grunt plugin is my next priority.

@spointecker
Copy link
Author

Thanks for your time!

@Ffloriel
Copy link
Member

The plugin has been updated. The Readme contains an example of a working configuration.
There is also an example here.
The documentation of purgecss will soon be updated to add grunt plugin to the list.

@spointecker
Copy link
Author

spointecker commented Apr 4, 2018

I am still having the same result with the new version and adapted config.
There is no purged.css file written

My config:

purgecss: {
        app: {
            options: {
                content: [path + '/**/*.html.twig']
            },
            files: {
                'purged.min.css': ['web/assets/css/app.css']
            }
        }
    },

Output is still the same as in the opening post (the var purgecssResult = new Purgecss({...) doesnt return anything.

Any ideas how to debug this? Is it possible to add more info output to the whole process?

@Ffloriel
Copy link
Member

Ffloriel commented Apr 5, 2018

Could you provide a repo that reproduce the issue?
One potential reason I can think of is if the paths to the files are not correct.

@Ffloriel Ffloriel reopened this Apr 5, 2018
@spointecker
Copy link
Author

spointecker commented Apr 11, 2018

Unfortunately it´s not that easy to provide an example of our grunt structure (working with subrepos...) due to its complexity.

@optimalisatie
Copy link

optimalisatie commented Apr 17, 2018

Hi!

We noticed the same issue. We hereby confirm that no CSS file is written.

image
image

Gruntfile.js config:

purgecss: {
    options: {
        content: ['html/*.html']
    },
    verkoop: {
        files: {
            'css/purged.css': ['../httpdocs/verkoop.css']
        }
    }
}

@jsnanigans
Copy link
Collaborator

@optimalisatie I think that could be one of two things

  1. node does not have rights to write the file css/purged.css or into the directory css
  2. the css directory does not exist, im not sure if purgecss can create it for you

@tofof
Copy link

tofof commented Aug 2, 2018

I also get no file written.
PurifyCSS has no trouble writing to the same path, so it's not (1).
The output directory exists, so it's not (2).

purgecss: {
      my_target: {
        options: {
          content: ['src/index.html']
        },
        files: {
          'out.css': ['src/in.css']
        }
      }
    }

EDIT: using the CLI revealed a thrown exception on a missing semicolon in my CSS source.
Grunt-purgecss still reported Done, without errors.

After fixing the missing semicolon, grunt-purgecss successfully wrote its output file.
Looks like your error detection is incomplete.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants