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.

Seems Webpack 2.* ExtractTextPlugin loader syntax smart merging is not working

See original GitHub issue

Assume we have webpack.common.js with follow loader section:

//...
   module: {
        rules: [
	//...
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                import: false,
                                url: false,
                                sourceMap: true,
                            },
                        },
                    ],
                }),
	    //...
            },
        ],
    },
//...

And in weback.test.js I want override this css loader typing:

var merge = webpackMerge.smart
return merge(commonConfig, {
        module: {
            rules: [
                {
                    test: /\.css$/,
                    use: [{
                        loader: 'null-loader',
                    }],
                },
            ],
        },
}

I get the following error:

TypeError: entry.loader.match is not a function at uniteEntries (\node_modules\webpack-merge\lib\join-arrays-smart.js:130:42) at arrayIncludesWith \node_modules\lodash_arrayIncludesWith.js:15:9)

The root cause is in the new ExtractTextPlugin syntax, which is not an array, or string, but it is a function written to loader property.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bebrawcommented, Jun 26, 2020

I’ll drop support for merge.smart and merge.smartStrategy in the next major version as it’s tricky to support due to different webpack versions and overall complexity.

Can you rewrite the configuration in terms of regular merge or mergeStrategy? I use solely merge for all of my personal work as it’s predictable.

0reactions
bebrawcommented, Nov 4, 2017

@sqfbeijing It’s tricky. I would push both behind a function or something to merge and then compose based on target. Less magic and cleaner as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

extract text plugin - ExtractTextPlugin not working at webpack 2
I found the solution: const ExtractTextPlugin = require("extract-text-webpack-plugin"); const extractSass = new ExtractTextPlugin({ filename: "[name].
Read more >
webpack/webpack - Gitter
Hi guys, we recently ported over our configuration from webpack 1.12.X to webpack 2.2.0-rc.3. And so far so good, our config has changed...
Read more >
How to conquer Webpack 4 and build a sweet React app
In this article, I'll go through how to set up a React application using Webpack 4. By the end of this tutorial, you'll...
Read more >
webpack has been initialised using a configuration object that ...
Invalid configuration object: Webpack has been initialized using a configuration object that does not match the API schema.
Read more >
Webpack Sass / Scss compiling to separate file - JonathanMH
npm install css-loader node-sass sass-loader webpack@2.2.0-rc.4 extract-text-webpack-plugin. Now let's say we have a project structure for a ...
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