pankajpatel / fontgen-loader

Forked from https://github.com/DragonsInn/fontgen-loader
5 stars 1 forks source link

How to use? #1

Open anchengjian opened 7 years ago

anchengjian commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

@anchengjian try this:

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

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

or simply use JSON config.