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.

Cannot read property 'contents' of undefined during build

See original GitHub issue

Using webpack v 4.29.6, my build fails at fontmin-webpack/lib/index.js:129, I get this error :

byExtension[item.extension].contents

TypeError: Cannot read property 'contents' of undefined

Here is some of my webpack config file : (I am also loading some .gif and .png files with file-loader, maybe it’s causing a conflict?)

module.exports = {
    mode: 'production',
    entry: entryObject,
    module: {
        rules: [
            {
                test: /(\.scss)$/,
                use: [
                    {
                        loader: MiniCssExtractPlugin.loader
                    },
                    {
                        loader: "css-loader" 
                    },
                    {
                        loader: "sass-loader",
                        options: {
                            implementation: require("node-sass")
                        }
                    }, 
                    {
                        loader: "postcss-loader",
                    }
                ]
            },
            {
                test: /\.(woff(2)?|ttf|eot|svg|gif|png)(\?v=\d+\.\d+\.\d+)?$/,
                use: [{
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]',
                            outputPath: '../fonts/'
                        }
                    }]
            },
        ]
    },
    plugins:
            [
                new MiniCssExtractPlugin({
                    filename: "../css/[name].css",
                    chunkFilename: "[id].css",
                }),
                new OptimizeCSSAssetsPlugin({}),
                new FontminPlugin({
                    autodetect: true, // automatically pull unicode characters from CSS
                }),
            ],
    devtool: false,
    }

}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickhulcecommented, Jul 1, 2019

Have you given it a shot with v2.0.4? I published what should be a fix for this error message but didn’t have a bug repro so 🤷‍♂

0reactions
patrickhulcecommented, Jul 2, 2019

Great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read property 'content' of undefined
messageDelete has only one argument see the example so message variable is undefined and you are trying to read 'content' of "message".
Read more >
Fatal error: Cannot read property 'contents' of undefined #208
I am trying to min all the images in a folder which has additional folders containing imgs inside of it. This issue only...
Read more >
"Cannot read property '$$' of undefined" in build : r/sveltejs
I've figured the issue. It's that the target element did not exist when the Svelte app was mounted. There are two options to...
Read more >
How To Fix Cannot read Property '0' of Undefined in JS
So why are you getting the TypeError mentioned above? You have most likely attempted to access your variable's contents while that variable has ......
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