Sha256: c8caa61f141c6a59955b460a22464639cb44a6ea0a7da442bf965a5d3989e232

Contents?: true

Size: 935 Bytes

Versions: 14

Compression:

Stored size: 935 Bytes

Contents

/* eslint global-require: 0 */
const { canProcess, moduleExists } = require('./helpers')
const inliningCss = require('./inliningCss')

const getStyleRule = (test, preprocessors = []) => {
  if (moduleExists('css-loader')) {
    const tryPostcss = () =>
      canProcess('postcss-loader', (loaderPath) => ({
        loader: loaderPath,
        options: { sourceMap: true }
      }))

    // style-loader is required when using css modules with HMR on the webpack-dev-server

    const use = [
      inliningCss ? 'style-loader' : require('mini-css-extract-plugin').loader,
      {
        loader: require.resolve('css-loader'),
        options: {
          sourceMap: true,
          importLoaders: 2,
          modules: {
            auto: true
          }
        }
      },
      tryPostcss(),
      ...preprocessors
    ].filter(Boolean)

    return {
      test,
      use
    }
  }

  return null
}

module.exports = getStyleRule

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shakapacker-7.2.3 package/utils/get_style_rule.js
shakapacker-7.3.0.beta.1 package/utils/get_style_rule.js
shakapacker-7.2.2 package/utils/get_style_rule.js
shakapacker-7.2.1 package/utils/get_style_rule.js
shakapacker-7.2.0 package/utils/get_style_rule.js
shakapacker-7.2.0.rc.0 package/utils/get_style_rule.js
shakapacker-7.1.0 package/utils/get_style_rule.js
shakapacker-7.0.3 package/utils/get_style_rule.js
shakapacker-7.0.2 package/utils/get_style_rule.js
shakapacker-7.0.1 package/utils/get_style_rule.js
shakapacker-7.0.0 package/utils/get_style_rule.js
shakapacker-7.0.0.rc.2 package/utils/get_style_rule.js
shakapacker-7.0.0.rc.1 package/utils/get_style_rule.js
shakapacker-7.0.0.rc.0 package/utils/get_style_rule.js