michael-ciniawsky / postcss-load-plugins

Autoload Plugins for PostCSS
Other
20 stars 6 forks source link

Doesn’t work with postcss-cli for some reason #6

Closed plashenkov closed 8 years ago

plashenkov commented 8 years ago

For some reason postcss-load-plugins doesn’t work with postcss-cli in my configuratin. Am I missing something?

Here is my package.json:

{
  "scripts": {
    "watch:js":  "watchify -vd -e app/views/js/index.js -o public_html/assets/index.js",
    "watch:css": "postcss -w -o public_html/assets/index.css app/views/css/index.css",
    "watch":     "npm-run-all --parallel watch:js watch:css"
  },
  "dependencies": {
    "normalize.css": "^4.2.0",
    "jquery": "^3.1.0",
    "vue": "^2.0.0-rc.2",
    "nouislider": "^8.5.1",
    "swiper": "^3.3.1",
    "malihu-custom-scrollbar-plugin": "^3.1.5"
  },
  "devDependencies": {
    "browserify": "^13.1.0",
    "watchify": "^3.7.0",
    "babel-core": "^6.13.2",
    "babel-preset-es2015": "^6.13.2",
    "babelify": "^7.3.0",
    "vueify": "^9.2.3",
    "uglify-js": "^2.7.1",
    "postcss-cli": "^2.5.2",
    "postcss-cssnext": "^2.7.0",
    "postcss-import": "^8.1.2",
    "postcss-load-plugins": "^2.0.0-alpha4",
    "postcss-url": "^5.1.2",
    "cross-env": "^2.0.0",
    "npm-run-all": "^2.3.0"
  },
  "browserify": {
    "transform": [
      "vueify",
      "babelify"
    ]
  },
  "babel": {
    "presets": ["es2015"]
  },
  "postcss": {
    "plugins": {
      "postcss-import": false,
      "postcss-cssnext": false,
      "postcss-url": false
    }
  }
}

Now trying to start: npm run watch:css. Here is the output:

> @ watch:css
> postcss -w -o public_html/assets/index.css app/views/css/index.css

Usage: /usr/bin/nodejs node_modules/.bin/postcss [--use|-u] plugin [--config|-c
config.json] [--output|-o output.css] [input.css]

[...]

Please specify at least one plugin name.

npm ERR! Linux 4.4.0-34-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch:css"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! @ watch:css: `postcss -w -o public_html/assets/index.css app/views/css/index.css`
npm ERR! Exit status 1

[...]

I’ve also tried to specify postcss-load-plugins as a plugin in command line (postcss -u postcss-load-plugins), but it does not work either.

Thank you in advance.

michael-ciniawsky commented 8 years ago

The problem is it's not integrated in postcss-cli atm :). The current way is described here --local-plugins. This module is more of a future PoC for a unified postcss.config.js approach as discussed here PostCSS #813. I sadly can't finish it right now, bc of other commitents i have. It would be only a PR to postcss-cli to change autoloading plugins with this module and get rid of the -c|config flag, when a postcss.config.js is present. For gulp,grunt and friends i need to change some slightly parts of it to work in a convenient way, e.g resolve the promise in this case and assign the plugins to a variable const plugins = require('postcss-load-config').plugins() (note: postcss-load-plugins + postcss-load-options === postcss-load-config :) )