Skip to content

mergeWithRules and shortcuts (loaders and use) #167

@just-jeb

Description

@just-jeb

Two questions:

  1. How would one merge loaders with use using mergeWithRules. Is it even possible? Any alternative?
  2. The following test fails with TypeError: Cannot read property 'options' of undefined.
    const conf1 = {
      module: {
        rules:[
          {
            "test": "/\\.scss$|\\.sass$/",
            "use": [
              {
                "loader": "sass-loader",
                "options": {
                  "sourceMap": true,
                  "sassOptions": {
                    "precision": 8,
                    "outputStyle": "expanded"
                  }
                }
              }
            ]
          }
        ]
      }
    };
    const conf2 = {
      module: {
        rules:[
          {
            "test": "/\\.scss$|\\.sass$/",
            "exclude": [
              "/node_modules/",
              "/v1/"
            ],
            "loaders": [
              {
                "loader": "sass-resources-loader",
                "options": {
                  "resources": [
                    "src/styles/includes.scss"
                  ]
                }
              }
            ]
          }
        ]
      }
    };

    const mergeRules = {
      module: {
        rules: {
          test: CustomizeRule.Match,
          use: {
            loader: CustomizeRule.Match,
            options: CustomizeRule.Merge,
          },
        },
      },
    }

    expect(mergeWithRules(mergeRules)(conf1, conf2)).toBeTruthy();

I'm not sure about that, but I wouldn't expect it to fail. WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions