# All files / src/webpack/inc babel-css-rule.js

100% Statements 10/10
100% Branches 4/4
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    942x
    2x

    2x
    2x

    2x

    2x
    8x
    8x

    16x

    6x

     const path = require("path");
    const directories = require("../utils/directories");

    const MiniCssExtractPlugin = require("mini-css-extract-plugin");
    const _ = require("lodash");

    const defaultOptions = {
      sourceMap: true,
      localIdentName: "[path][name]__[local]",
      compress: false,
    };

    module.exports = module.exports.default = (options) => {
      const o = _.assignIn({}, defaultOptions, options);
      return [
        {
          test: /\.(sass|scss|css)$/,
          exclude: [
            path.join(directories.src, "resources"),
            path.join(directories.root, "node_modules"),
          ],
          use: [
            MiniCssExtractPlugin.loader,
            {
              loader: "css-loader",
              options: {
                modules: true,
                localIdentName: o.localIdentName,
                sourceMap: o.sourceMap,
                minimize: o.compress,
                importLoaders: 2
              }
            },
            {
              loader: "postcss-loader",
              options: {
                sourceMap: o.sourceMap,
                ident: "postcss",
                plugins: () => [
                  require("postcss-preset-env")()
                ]
              }
            },
            {
              loader: "sass-loader",
              options: {
                outputStyle: o.compress ? "compressed": "expanded",
                sourceMap: o.sourceMap,
                sourceMapContents: o.sourceMap,
              }
            }
          ]
        },
        {
          test: /\.(sass|scss|css)$/,
          include: [
            path.join(directories.src, "resources"),
            path.join(directories.root, "node_modules"),
          ],
          use: [
            MiniCssExtractPlugin.loader,
            {
              loader: "css-loader",
              options: {
                modules: true,
                localIdentName: "[local]",
                sourceMap: o.sourceMap,
                minimize: o.compress,
                importLoaders: 2
              }
            },
            {
              loader: "postcss-loader",
              options: {
                sourceMap: o.sourceMap,
                ident: "postcss",
                plugins: () => [
                  require("postcss-preset-env")()
                ]
              }
            },
            {
              loader: "sass-loader",
              options: {
                outputStyle: o.compress ? "compressed": "expanded",
                sourceMap: o.sourceMap,
                sourceMapContents: o.sourceMap,
              }
            }
          ]
        },
      ];
    };