Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'content' of undefined #146

Closed
andrejs-uibo opened this issue Jan 26, 2021 · 7 comments
Closed

TypeError: Cannot read property 'content' of undefined #146

andrejs-uibo opened this issue Jan 26, 2021 · 7 comments

Comments

@andrejs-uibo
Copy link

andrejs-uibo commented Jan 26, 2021

When trying to build assets, I get this error:

node_modules/svg-spritemap-webpack-plugin/lib/index.js:209
                        this.stylesType = this.getStylesType(this.styles.content, stylesOptions.filename);
                                                                         ^
TypeError: Cannot read property 'content' of undefined

Here is a part of webpack config how I use this plugin:

plugins: [
    new SVGSpritemapPlugin("frontend/web/images/features/*.svg", {
      output: {
        filename: "features.svg",
      },
      styles: {
        keepAttributes: true,
        filename: "features.css",
      },
    }),
...

This is on webpack v5.16.0
Plugin v3.8.3

@andrejs-uibo
Copy link
Author

andrejs-uibo commented Jan 26, 2021

This could be related to #143

Probably need to exit early

if (typeof this.styles === 'undefined') {
    return;
}

before

if ( this.styles && this.styles.warnings && this.styles.warnings.length ) {

@cascornelissen
Copy link
Owner

Had a quick look and I've made a similar change in 2b72654 which should also solve this. Would you mind trying to install the plugin from master by using the following command and letting me know if this also solves the problem you're running into?

$ npm install cascornelissen/svg-spritemap-webpack-plugin#master

@cascornelissen
Copy link
Owner

ping @andrejs-uibo

@andrejs-uibo
Copy link
Author

andrejs-uibo commented Feb 4, 2021

Sorry, have not had the time to check, but it seems like it should solve the issue.

@Veron116
Copy link

There is an error if change the style option
error in ./node_modules/svg-spritemap-webpack-plugin/svg4everybody-helper.js

@cascornelissen
Copy link
Owner

@Veron116, do you have any more information? Are you talking about the latest release on NPM or the master branch?

@cascornelissen
Copy link
Owner

This change was included in 3.9.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants