R
R
Roman Govorov2022-01-17 13:12:28
webpack
Roman Govorov, 2022-01-17 13:12:28

MediaQueryPlugin how to load images used in CSS media queries?

I'm using the media-query-plugin to extract media queries into separate files.

At this stage:

// webpack.common.js
{
  test: /\.(sa|sc|c)ss$/,
      use: [
  {
    loader: MiniCssExtractPlugin.loader,
    options: {
      publicPath: paths.images,
    },
  },
  'css-loader',
  MediaQueryPlugin.loader,
  'postcss-loader',
  'sass-loader'
]
},


The MediaQueryPlugin module drags all media queries into separate files and throws them into a folder:
// webpack.common.js
new MediaQueryPlugin({
  include: ['main', 'pages', 'posts', 'admin'],
  filename: '../../min/css/[name].[ext]',
  queries: {
    'screen and (max-width: 1399.98px)': 'max-1400',
    'screen and (max-width: 1199.98px)': 'max-1200',
    'screen and (max-width: 991.98px)': 'max-992',
    'screen and (max-width: 767.98px)': 'max-768',
    'screen and (max-width: 575.98px)': 'max-576',
  },
}),


But the images used in these media queries ( background: url(....) ) are ignored by it, and postcss is not applied, while all other files work, only what I cut out is not ale ... how to solve this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question