icons-loader icon indicating copy to clipboard operation
icons-loader copied to clipboard

Cannot read property 'addIcon' of undefined

Open airzym opened this issue 8 years ago • 1 comments

After following the workflow integration in the README, when running weback I get the following error:

ERROR in ./src/icons/close.svg
Module build failed: TypeError: Cannot read property 'addIcon' of undefined
    at Object.module.exports (C:\...\node_modules\icons-loader\index.js:8:43)
 @ ./src/icons/index.js 11:13-35
 @ ./src/components/presentation/icon/index.js
 @ ./src/components/presentation/nav/index.js
 @ ./src/components/App.js
 @ ./src/index.js

My webpack:

var webpack = require("webpack");
var path = require("path");
var iconsPlugin = require("icons-loader/IconsPlugin");

module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.resolve("./wwwroot"),
        filename: "bundle.js",
        publicPath: "/"
    },
    module: {
        rules: [
            {
                enforce: "pre",
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "eslint-loader"
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            },
            {
                test: /\.scss$/,
                exclude: /node_modules/,
                loaders: ["style-loader", "css-loader", "sass-loader"]
            },
            {
                test: /\.svg$/,
                exclude: /node_modules/,
                use: [{
                    loader: "icons-loader",
                    options: {
                        plugins: [
                            new iconsPlugin({
                                fontName: "icons",
                                normalize: true,
                                formats: ["ttf", "eot", "woff", "svg"]
                            })
                        ]
                    }
                }]
            }
        ]
    }

My project.json

{
  "main": "src/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "npm run clean && webpack --watch --devtool eval-source-map --progress",
    "build": "npm run clean && webpack --progress",
    "clean": "rimraf wwwroot/bundle.js"
  },
  "dependencies": {
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "^5.0.2",
    "redux": "^3.6.0",
    "redux-logger": "^2.8.1",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-core": "^6.22.1",
    "babel-eslint": "^7.1.1",
    "babel-loader": "^6.2.10",
    "babel-preset-es2015": "^6.22.0",
    "babel-preset-react": "^6.22.0",
    "css-loader": "^0.26.1",
    "eslint": "^3.14.1",
    "eslint-loader": "^1.6.1",
    "eslint-plugin-react": "^6.9.0",
    "icons-loader": "0.0.6",
    "node-sass": "^4.5.0",
    "rimraf": "^2.5.4",
    "sass-loader": "^4.1.1",
    "style-loader": "^0.13.1",
    "webpack": "^2.2.1"
  }
}

Any help on what I'm doing wrong?

airzym avatar Feb 06 '17 16:02 airzym

+1

receptiryaki avatar Feb 20 '18 12:02 receptiryaki