question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Merging two module.rules just appends

See original GitHub issue

This is the test I want to run but it seems that the latest version does not longer merge rules.

  it('Should merge loader options', () => {
    const output = merge(
      {
        module: {
          rules: [
            {
              test: /\.css$/,
              use: [{ loader: 'style-loader' }, { loader: 'sass-loader' }],
            },
          ],
        },
      },
      {
        module: {
          rules: [
            {
              test: /\.css$/,
              use: [
                {
                  loader: 'style-loader',
                  options: {
                    modules: true,
                  },
                },
              ],
            },
          ],
        },
      }
    );

    const expected = {
      module: {
        rules: [
          {
            test: /\.css$/,
            use: [
              {
                loader: 'style-loader',
                options: {
                  modules: true,
                },
              },
              { loader: 'sass-loader' },
            ],
          },
        ],
      },
    };

    expect(output).toEqual(expected);
  });

Output is:

  [
        { test: /\.css$/, use: [ [Object], [Object] ] },
        { test: /\.css$/, use: [ [Object] ] }
      ]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
bebrawcommented, Sep 3, 2020

@muuvmuuv Yeah, using a strategy would fit well. I’ll go that way (might need a day or two due to other work).

1reaction
bebrawcommented, Sep 7, 2020

@muuvmuuv Yeah, that’s a good idea since then you could build more matchers. I have to check the code to understand the implications but I see the use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using webpack-merge to prepend loaders to a rules `use` array
So I tried to use merge.smartStrategy({ 'module.rules.use': 'prepend' })() , but I get an error: TypeError: this[MODULE_TYPE] ...
Read more >
Composing Configuration - SurviveJS
In composition based approach, you split webpack configuration and then merge it together. The problem is that a normal way of merging objects...
Read more >
Solved: Join/Append 2 Lists - Anaplan Community
Solved: Hi team, This is an usual question but I have 2 lists (1 customer & 1 future revenue to be derived off...
Read more >
Node.js — How to Merge Objects - Future Studio
Remember that Object.assign modifies the target object (the first parameter). To ensure a new object without changing any of the sources, you ...
Read more >
Merge/Append using Stata - Princeton University
Merge – adds variables to a dataset. ... Merging two datasets require that both have at least one variable in ... If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found