-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build umd module; slim down by allowing to add individual icons and n…
…ot include FA in the package; set react + FA as peerDependencies; add source-maps;
- Loading branch information
1 parent
ed51318
commit d9b48a1
Showing
8 changed files
with
74 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": [ "@babel/preset-env", "@babel/preset-react" ] | ||
"presets": [ "@babel/preset-react" ] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,23 @@ | ||
import React from 'react'; | ||
import { library } from '@fortawesome/fontawesome-svg-core'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import * as freeSolidSvgIcons from '@fortawesome/free-solid-svg-icons'; | ||
import * as freeBrandsSvgIcons from '@fortawesome/free-brands-svg-icons'; | ||
import * as freeRegularSvgIcons from '@fortawesome/free-regular-svg-icons'; | ||
|
||
|
||
const isMatch = key => ( key.match(/^fa[A-Z]/g) !== null ); | ||
|
||
const iconSets = [freeSolidSvgIcons, freeBrandsSvgIcons, freeRegularSvgIcons]; | ||
|
||
const faIcons = iconSets.map( iconSet => ( | ||
Object.keys(iconSet).reduce( (acc, cur) => { | ||
if (isMatch(cur)) { | ||
library.add(iconSet[cur]); | ||
return { | ||
...acc, | ||
[`${iconSet[cur].prefix} ${iconSet[cur].iconName}`]: { | ||
isSvg: true, | ||
icon: () => <FontAwesomeIcon icon={iconSet[cur]} />, | ||
}, | ||
}; | ||
} | ||
return acc; | ||
}, {}) | ||
)).reduce( (acc, curr) => ({ ...acc, ...curr }), {}); | ||
const wrapLibrary = lib => { | ||
return Object.keys(lib.definitions).reduce( (acc, prefix) => { | ||
return { | ||
...acc, | ||
...Object.keys(lib.definitions[prefix]).reduce( (acc2, iconName) => { | ||
return { | ||
...acc2, | ||
[`${prefix} ${iconName}`]: { | ||
isSvg: true, | ||
icon: () => <FontAwesomeIcon icon={{prefix, iconName, icon: lib.definitions[prefix][iconName]}} />, | ||
} | ||
}; | ||
}, {}) | ||
}; | ||
}, {}); | ||
} | ||
|
||
export { | ||
faIcons, | ||
wrapLibrary, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
entry: './src/index.js', | ||
output: { | ||
library: 'stardust-ui-font-awesome-plugin', | ||
libraryTarget: 'umd', | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
exclude: /node_modules/, | ||
use: { loader: 'babel-loader' } | ||
} | ||
] | ||
}, | ||
externals: [ | ||
{ | ||
react: 'react', | ||
'@fortawesome/react-fontawesome': '@fortawesome/react-fontawesome' | ||
} | ||
] | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const merge = require('webpack-merge'); | ||
const common = require('./webpack.common.js'); | ||
|
||
module.exports = merge(common, { | ||
mode: 'development', | ||
devtool: 'inline-source-map', | ||
devServer: { | ||
contentBase: './dist' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const merge = require('webpack-merge'); | ||
const common = require('./webpack.common.js'); | ||
|
||
module.exports = merge(common, { | ||
mode: 'production', | ||
devtool: 'source-map', | ||
}); |