Skip to content

Instantly share code, notes, and snippets.

@vladkosinov
Created November 2, 2015 20:45
Show Gist options
  • Save vladkosinov/2d0497be4e9eece144d1 to your computer and use it in GitHub Desktop.
Save vladkosinov/2d0497be4e9eece144d1 to your computer and use it in GitHub Desktop.
How to use stylelint with postcss loader
{
...
module: {
loaders: [
{test: CSS_REGEX, loaders: ['style', 'css', 'postcss']},
]
},
postcss: () => [require('stylelint'), require('postcss-reporter')]
}
@vyorkin
Copy link

vyorkin commented Nov 21, 2015

The same. In my case it says:

ERROR in ./~/css-loader?importLoaders=1&modules!./~/postcss-loader!./src/scripts/pages/examples/Counter/components/Counter/style.css
Module build failed: Error: No rules found within configuration
    at exports.default (/Users/vyorkin/github/starter-kit/node_modules/stylelint/dist/utils/configurationError.js:8:13)
    at /Users/vyorkin/github/starter-kit/node_modules/stylelint/dist/postcssPlugin.js:52:43
    at LazyResult.run (/Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:201:20)
    at /Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:115:37
    at LazyResult.asyncTick (/Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:129:15)
    at processing.Promise.then._this2.processed (/Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:155:20)
    at new Promise (/Users/vyorkin/github/starter-kit/node_modules/core-js/modules/es6.promise.js:197:7)
    at LazyResult.async (/Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:152:27)
    at LazyResult.then (/Users/vyorkin/github/starter-kit/node_modules/postcss/lib/lazy-result.js:75:21)
    at Object.module.exports (/Users/vyorkin/github/starter-kit/node_modules/postcss-loader/index.js:47:32)
 @ ./src/scripts/pages/examples/Counter/components/Counter/style.css 4:14-178 13:2-17:4 14:20-184

But: using stylelintrc from: /Users/vyorkin/github/starter-kit/.stylelintrc and its really there. Works from CLI

@moimikey
Copy link

you need to have rules, even if they're empty:

      require('postcss-import')({
        addDependencyTo: webpack,
        path: ['node_modules', 'src'],
        plugins: [
          require('stylelint')({
            extends: 'stylelint-config-standard',
            rules: []
          })
        ]
      }),
      require('stylelint')({
        extends: 'stylelint-config-standard',
        rules: []
      }),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment