2

I'm trying to extract some media queries from my css bundles, but unfortunately plugin is not working.

ERROR in ./node_modules/css-loader!./node_modules/postcss-loader/src!./node_modules/jscrollpane/style/jquery.jscrollpane.css
    Module build failed: TypeError: Invalid PostCSS Plugin found at: plugins[0]


Here is my postcss.config.js

const path = require('path');

module.exports = {
    plugins: [
        {
            'postcss-extract-media-query': {
                output: {
                    path: path.join(__dirname, 'dist'),
                    name: '[name]-[query].[ext]'
                },
                queries: {
                    'screen and (min-width: 1024px)': 'desktop'
                }
            }
        }
    ]
}

Postcss works fine without it, at least I don't have any errors

Part of webpack.config.js, I doubt I have any problems here since it works fine

cssLoader = [ 'css-loader', 'postcss-loader'],

return {
    module: {
        rules: [ { test: /\.css$/, use:  cssLoader  },]
    }
}

Part of my package.json

    "postcss": "^7.0.14",
    "postcss-extract-media-query": "^1.2.0",
    "postcss-loader": "^3.0.0",
    "webpack": "^3.12.0",

Do you have any idea why it's not working?

UPD:

I don't have any errors if I will use it as follows:

module.exports = {
    plugins: [
            require('postcss-extract-media-query'),
    ] }

But I need to set up some options as well, so it's not working for me

alexlz
  • 618
  • 1
  • 10
  • 24

0 Answers0