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

How to use? #1

Open
anchengjian opened this issue Jan 23, 2017 · 4 comments
Open

How to use? #1

anchengjian opened this issue Jan 23, 2017 · 4 comments

Comments

@anchengjian
Copy link

anchengjian commented Jan 23, 2017

  1. How to use?
  2. Compared to fontgen-loader, what changes ?

According to the document, I got an error

ERROR in ./src/main.js
Module not found: Error: Cannot resolve module 'fontgen' in E:/code/src

then I rewrite the weboack.config

{
      test: /\.font\.(js|json)$/,
      loader: "font-gen"
}

got another error

ERROR in ./config/icon.font.js
Module build failed: Error: "options.files" is empty.
    at webfont (E:/code/node_modules/webfonts-generator/src/index.js:53:41)
    at Object.module.exports (E:/code/node_modules/font-gen-loader/index.js:160:5)
@pankajpatel
Copy link
Owner

It is completely similar to the fontgen-loader but with few extra options/fixes that were not there or not merged.

Please see the test directory in the repo to have brief example about the usage.

The last error might be related to the files key in the following code example:

module.exports = {
    fontName: "Octicons",
    files: ["./octicons/svg/*.svg"],
    baseClass: "octicon",
    classPrefix: "octicon-",
    cssFile: 'css'
};

Please provide your snippet of code in config/icon.font.js

@anchengjian
Copy link
Author

image

module.exports = {
  "fontName": "Octicons",
  "files": ["assets/icon/*.svg"],
  "baseClass": "octicon",
  "classPrefix": "octicon-",
  "cssFile": "css"
}
ERROR in ./config/icon.font.js
Module build failed: Error: "options.files" is empty.
    at webfont (E:/code/node_modules/webfonts-generator/src/index.js:53:41)
    at Object.module.exports (E:/code/node_modules/font-gen-loader/index.js:160:5)
 @ ./src/main.js 26:0-27

@pankajpatel
Copy link
Owner

Does any file match the glob pattern assets/icon/*.svg?

I was able to reproduce the error when there are no files which match to glob pattern. Put some svg files in assets/icon to see it working.

@IlyaSemenov
Copy link
Contributor

@anchengjian try this:

var glob = require("glob").sync;

module.exports = {
    fontName: "Octicons",
    files: glob("assets/icon/*.svg", {cwd: __dirname}),
...

or simply use JSON config.

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

No branches or pull requests

3 participants