forked from jantimon/iconfont-webpack-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (31 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
let _ = require('lodash');
let assert = require('assert');
module.exports = function IconfontWebpackPlugin (userOptions) {
// Default options
const options = _.extend({
// allows to prefix the font name to prevent collisions
fontNamePrefix: '',
// the svg size requires all svgs to have the same height
// usually scaling the icons to 1000px should be fine but if you prefer
// another value set it here
enforcedSvgHeight: 1000,
// resolve function to translate webpack urls into absolute filepaths
// e.g. url('demo.svg') -> '/Users/me/project-x/demo.svg'
// usually you should pass on the postcss loader
// https://webpack.js.org/api/loaders/#this-resolve
resolve: undefined
}, userOptions);
// Verify resolve function
assert(typeof options.resolve === 'function',
'Please pass a resolve function to the IconFontWebpackPlugin.\n' +
'For example: \n' +
'{\n' +
' loader: \'postcss-loader\',\n' +
' options: {\n' +
' plugins: (loader) => [\n' +
' require(\'iconfont-webpack-plugin\')({ resolve: loader.resolve }), \n\n'
);
// Call postcss plugin
return require('./lib/postcss-plugin')(options);
};