Git Product home page Git Product logo

icons-loader's People

Contributors

flgmwt avatar mikevercoelen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

icons-loader's Issues

icon can't show

dear!
i use icons-loader but they show "", what wrong whit is? and what can i do.
thank a lot..

Cannot read property 'apply' of null

I'm getting this error with [email protected]:

 webpack                                    
/home/pcfl/.nvm/versions/node/v6.2.1/lib/node_modules/webpack/bin/webpack.js:315
		throw e;
		^

TypeError: Cannot read property 'apply' of null
    at IconsPlugin.apply (/home/pcfl/gflow/project/node_modules/icons-loader/IconsPlugin.js:38:30)
    at Compiler.apply (/home/pcfl/.nvm/versions/node/v6.2.1/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:306:16)
    at webpack (/home/pcfl/.nvm/versions/node/v6.2.1/lib/node_modules/webpack/lib/webpack.js:32:19)
    at processOptions (/home/pcfl/.nvm/versions/node/v6.2.1/lib/node_modules/webpack/bin/webpack.js:305:14)
    at Object.<anonymous> (/home/pcfl/.nvm/versions/node/v6.2.1/lib/node_modules/webpack/bin/webpack.js:363:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:456:3

woff2 support

I'm wondering woff2 isn't supported since gulp-iconfonts is able to create it?

CSS Generation

It would be nice to have automatic CSS generation included in this loader.

This is a gulp extension I wrote that I'm wonder if your interested on collaborating on integrating. This also generates a HTML preview of the icons too.

build.icons.js

var gulp = require('gulp');
var iconfont = require('gulp-iconfont');
var iconfontCss = require('gulp-iconfont-css');
var paths = require('./paths');
var consolidate = require('gulp-consolidate');

gulp.task('build:icons', function(done) {
  var fontName = 'icons';
  var cssClass = 'icon';

  return gulp.src(paths.svgs)
    .pipe(iconfontCss({
      fontName,
      cssClass: cssClass,
      targetPath: 'styles/icons.css',
      fontPath: 'fonts/icons/',
      path: 'template.css'
    }))
    .pipe(iconfont({
      fontName,
      normalize:true,
      fontHeight: 1001,
      log: () => {},
      formats: ['ttf', 'eot', 'woff', 'svg']
    }))
    .on('glyphs', function(glyphs, options) {
      gulp.src('template.html')
        .pipe(consolidate('lodash', {
          glyphs: glyphs,
          fontName: fontName,
          cssClass: cssClass
        }))
        .pipe(gulp.dest(`${paths.output}assets/fonts/icons`));
    })
    .pipe(gulp.dest(`${paths.output}assets/fonts/icons`));
});

template.css

@charset "UTF-8";

@font-face {
    font-family: "<%= fontName %>";
    src: url('<%= fontPath %><%= fontName %>.eot');
    src: url("../assets/fonts/fontastic/swimlane.eot?#iefix") format("embedded-opentype"),
        url('<%= fontPath %><%= fontName %>.woff') format('woff'),
        url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
        url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');

    font-weight: normal;
  font-style: normal;
}

[class^="<%= cssClass %>-"]:before,
[class*=" <%= cssClass %>-"]:before {
    font-family: "<%= fontName %>"  !important;
    speak: none;
    line-height: 1;

    font-style: normal !important;
    font-weight: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    text-decoration: none !important;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

<% _.each(glyphs, function(glyph) { %>
.<%= cssClass %>-<%= glyph.fileName %>:before {
    content: "\<%= glyph.codePoint %>";
}
<% }); %>

template.html


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Font Reference - Swimlane</title>
    <link rel="stylesheet" href="../../styles/icons.css">
    <style type="text/css">html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:100%;vertical-align:baseline}body{line-height:1;color:#000;background:#fff}ol,ul{list-style:none}table{border-collapse:separate;border-spacing:0;vertical-align:middle}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}a img{border:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{font-family:'Dosis','Tahoma',sans-serif}.container{margin:15px auto;width:80%}h1{margin:40px 0 20px;font-weight:700;font-size:38px;line-height:32px;color:#fb565e}h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercase;font-weight:500}.small{font-size:14px;color:#a5adb4;}.small a{color:#a5adb4;}.small a:hover{color:#fb565e}.glyphs.character-mapping{margin:0 0 20px 0;padding:20px 0 20px 30px;color:rgba(0,0,0,0.5);border:1px solid #d8e0e5;-webkit-border-radius:3px;border-radius:3px;}.glyphs.character-mapping li{margin:0 30px 20px 0;display:inline-block;width:90px}.glyphs.character-mapping .icon{margin:10px 0 10px 15px;padding:15px;position:relative;width:55px;height:55px;color:#162a36 !important;overflow:hidden;-webkit-border-radius:3px;border-radius:3px;font-size:32px;}.glyphs.character-mapping .icon svg{fill:#000}.glyphs.character-mapping input{margin:0;padding:5px 0;line-height:12px;font-size:12px;display:block;width:100%;border:1px solid #d8e0e5;-webkit-border-radius:5px;border-radius:5px;text-align:center;outline:0;}.glyphs.character-mapping input:focus{border:1px solid #fbde4a;-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.character-mapping input:hover{-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.css-mapping{margin:0 0 60px 0;padding:30px 0 20px 30px;color:rgba(0,0,0,0.5);border:1px solid #d8e0e5;-webkit-border-radius:3px;border-radius:3px;}.glyphs.css-mapping li{margin:0 30px 20px 0;padding:0;display:inline-block;overflow:hidden}.glyphs.css-mapping .icon{margin:0;margin-right:10px;padding:13px;height:50px;width:50px;color:#162a36 !important;overflow:hidden;float:left;font-size:24px}.glyphs.css-mapping input{margin:0;margin-top:5px;padding:8px;line-height:16px;font-size:16px;display:block;width:150px;height:40px;border:1px solid #d8e0e5;-webkit-border-radius:5px;border-radius:5px;background:#fff;outline:0;float:right;}.glyphs.css-mapping input:focus{border:1px solid #fbde4a;-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.css-mapping input:hover{-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}</style>
  </head>
  <body>
    <div class="container">
      <h1>Swimlane: <%= fontName %></h1>
      <ul class="glyphs css-mapping">
        <% _.each(glyphs, function(glyph) { %>
        <li>
          <div class="icon <%= cssClass %>-<%= glyph.name %>"></div>
          <input type="text" readonly="readonly" value="<%= cssClass %>-<%= glyph.name %>">
        </li>
        <% }); %>
      </ul>
    </div>
    <script>
      (function() {
        var glyphs, i, len, ref;
        ref = document.getElementsByClassName('glyphs');
        for (i = 0, len = ref.length; i < len; i++) {
          glyphs = ref[i];
          glyphs.addEventListener('click', function(event) {
            if (event.target.tagName === 'INPUT') {
              return event.target.select();
            }
          });
        }
      }).call(this);
    </script>
  </body>
</html>

Cannot read property 'addIcon' of undefined

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?

Error: Non-whitespace before first tag.

Hi,

for every svg-icon i want to use, i get the following error log:

Listening at http://localhost:8080

webpack: wait until bundle finished: /__webpack_hmr
/src/node_modules/webpack-dev-middleware/middleware.js

:106
                        if(err) throw err;
                                ^

Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: m
    at error (/src/node_modules/sax/lib/sax.js:667:10)
    at strictFail (/src/node_modules/sax/lib/sax.js:69
3:7)
    at beginWhiteSpace (/src/node_modules/sax/lib/sax.
js:967:7)
    at Object.write (/src/node_modules/sax/lib/sax.js:
1019:11)
    at SAXStream.write (/src/node_modules/sax/lib/sax.
js:239:18)
    at PassThrough.ondata (/src/node_modules/readable-

After some research, this seems to be a problem with UTF8-Encoded SVGs. I'm not that into node-Modules, so could you provide a fix for this?
Here is a possible solution

I use icons from iconmonstr.com, but even self-generated icons with Sketch or Illustrator doesn't work.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.