/
index.js
42 lines (35 loc) · 1.23 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
39
40
41
42
'use strict';
const fs = require('fs');
const path = require('path');
const plexPath = path.dirname(require.resolve('@ibm/plex/package.json'));
const plexPkg = require('@ibm/plex/package.json');
module.exports = {
name: 'ember-font-plex',
included: function() {
this._super.included.apply(this, arguments);
let options = (this.app.options['ember-font-plex'] =
this.app.options['ember-font-plex'] || {});
let fonts = (options['fonts'] || ['IBM Plex Sans']).map(fontFamily =>
fontFamily.replace(/\s/g, '-')
);
let version = plexPkg.version;
fonts.forEach(fontFamily => {
this.import(`vendor/${fontFamily.toLowerCase()}.css`);
});
fonts.forEach(fontFamily => {
let fontPath = path.join(fontFamily, 'fonts/split');
['woff', 'woff2'].forEach(format => {
let absoluteFontsPath = path.join(plexPath, fontPath, format);
let fontsToImport = fs.readdirSync(absoluteFontsPath);
fontsToImport.forEach(filename => {
this.import(
path.join('node_modules/@ibm/plex', fontPath, format, filename),
{
destDir: path.join('assets/fonts', fontFamily, version, format)
}
);
});
});
});
}
};