nDmitry / grunt-postcss

Apply several post-processors to your CSS using PostCSS.
MIT License
419 stars 57 forks source link

PostCSS does not read and not print file, from folder "src" to "dest" #94

Open immagimario opened 8 years ago

immagimario commented 8 years ago

I installed grunt-postcss and autoprefixer plug-in, but when I try to configure PostCSS with metod of the plug-in "load-grunt-config", Autoprefixer and other plug-in, do nothing and do not have allert or error.

This is output from console:

$ grunt postcss
Running "postcss:postcss" (postcss) task
Done.

When I configure grunt in the standard way, PostCSS it works correctly.

This is my postcss.js file, put inside of grunt folder:

module.exports = {
  postcss: {
    options: {
      processors: [
        require('autoprefixer')(),
      ]
    },
    dist: {
      src: '<%= project.stylesheets %>/src/main.css',
      dest: '<%= project.stylesheets %>/dest/main.css'
    }
  }
};

Instead, with this command grunt postcss --debug, the consoole display this:

Running "postcss:postcss" (postcss) task
[D] Task source: /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-postcss/tasks/postcss.js
Done.

Or this command line $grunt postcss --verbose, the consoole display this:

$ grunt postcss --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Initializing config...OK

Registering "grunt-bowercopy" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-bowercopy/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-bowercopy/package.json...OK
Reading bower.json...OK
Parsing bower.json...OK
Loading "bowercopy.js" tasks...OK
+ bowercopy

Registering "grunt-contrib-sass" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-contrib-sass/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-contrib-sass/package.json...OK
Loading "sass.js" tasks...OK
+ sass

Registering "grunt-contrib-watch" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-contrib-watch/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch

Registering "grunt-modernizr" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-modernizr/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-modernizr/package.json...OK
Loading "modernizr.js" tasks...OK
+ modernizr

Registering "grunt-postcss" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-postcss/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-postcss/package.json...OK
Loading "postcss.js" tasks...OK
+ postcss

Registering "grunt-slim" local Npm module tasks.
Reading /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-slim/package.json...OK
Parsing /Users/mario.montalto/Progetti/start-web-site/frontend/node_modules/grunt-slim/package.json...OK
Loading "slim.js" tasks...OK
+ slim
Loading "Gruntfile.js" tasks...OK
+ default

Running tasks: postcss

Running "postcss" task

Running "postcss:postcss" (postcss) task
Verifying property postcss.postcss exists in config...OK
File: [no files]
Options: processors=[null], map, diff=false, safe=false, failOnError=false, writeDest

Done.

You have no idea how to solve it

Thanks for your help

Mario

talgautb commented 8 years ago

the same problem, i want use 2 postcss task, not working using dest and src. @nDmitry maybe @ai know ?

talgautb commented 8 years ago

@immagimario i fix my problem:

postcss: {
      main: {
        options: {
          map: false,
          processors: [
            require('autoprefixer')({
              browsers: '> 1%'
            })
          ]
        },
        src: '<%= appConfig.app %>/css/main.css'
      },
      new: {
        options: {
          map: false,
          processors: [
            require('autoprefixer')({
              browsers: '> 10%'
            })
          ]
        },
        src: './app/css/main.css',
        dest: './app/css/new_main.css'
      }
    },
immagimario commented 8 years ago

@talgautb

Hi I tried the solution that you suggested. but the console output print this error:

Running "postcss: postcss" (postcss) task
Verifying property postcss.postcss exists in config ... OK
File: [no files]
Options: processors = [], map = false, diff = false, safe = false, FailOnError = false, writeDest

I finally used this syntax:

module.exports = {
   postcss {// please note: in this case this is not target name plugin name (so you can put any keyword, like: foo or dist or production etc.)
     options: {
       processors: [
         require ('autoprefixer') ({browsers: ['last 2 versions']}),
       ]
     },
files: {
'<% = Project.stylesheets%> / dest / main.css': '<% = project.stylesheets%> / src / main.css',
'<% = Project.stylesheets%> / dest / vendor.css': '<% = project.stylesheets%> / src / vendor.css',
   }
   }
};

Thank you very much for helping ;-)

BrockBeldham commented 7 years ago

I had a similar problem and this syntax worked for me, so might work for you?

module.exports = {
   postcss: {
     options: {
       map: true,
       processors: [
         require ('autoprefixer') ({browsers: ['last 2 versions']}),
       ]
     },
      cwd: '<% = Project.stylesheets%>/dest/',
      src: '*.css',
      dest: '<% = Project.stylesheets%>/src/',
      expand: true,
      ext: '.css'
   }
};