diff --git a/README.md b/README.md
index 6c0ee8c0..87f6be27 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,23 @@ console.log(simpleIcons['Google+']);
*/
```
+Alternatively you can import the needed icons individually.
+This is useful if you are e.g. compiling your code with [webpack](https://webpack.js.org/) and therefore have to be mindful of your package size:
+
+```js
+const googleplus = require('simple-icons/icons/googleplus');
+
+console.log(googleplus);
+/*
+{
+ title: 'Google+',
+ hex: 'DC4E41',
+ source: 'https://developers.google.com/+/branding-guidelines',
+ svg: ''
+}
+*/
+```
+
## Third Party Extensions
### WordPress
diff --git a/_data/simple-icons.json b/_data/simple-icons.json
index 7e621a99..571fc8d6 100644
--- a/_data/simple-icons.json
+++ b/_data/simple-icons.json
@@ -75,6 +75,11 @@
"hex": "FF5A5F",
"source": "https://www.airbnb.com"
},
+ {
+ "title": "Go",
+ "hex": "76E1FE",
+ "source": "https://golang.org/doc/gopher/"
+ },
{
"title": "Google Allo",
"hex": "ECB842",
@@ -260,6 +265,11 @@
"hex": "509CF6",
"source": "https://www.campaignmonitor.com/brand"
},
+ {
+ "title": "Castorama",
+ "hex": "0078D7",
+ "source": "https://www.castorama.fr/"
+ },
{
"title": "Castro",
"hex": "00B265",
@@ -470,6 +480,11 @@
"hex": "72BE50",
"source": "http://www.empire.kred"
},
+ {
+ "title": "Envato",
+ "hex": "81B441",
+ "source": "https://envato.com/"
+ },
{
"title": "Ethereum",
"hex": "3C3C3D",
@@ -840,6 +855,11 @@
"hex": "FF3366",
"source": "https://projects.invisionapp.com/boards/BX4P1DY5H46R"
},
+ {
+ "title": "Java",
+ "hex": "007396",
+ "source": "https://www.oracle.com/legal/logos.html"
+ },
{
"title": "JavaScript",
"hex": "F7DF1E",
@@ -1037,8 +1057,8 @@
},
{
"title": "Mastodon",
- "hex": "189EFC",
- "source": "https://github.com/tootsuite/mastodon/blob/master/app/assets/images/logo.svg"
+ "hex": "3088D4",
+ "source": "https://source.joinmastodon.org/mastodon/joinmastodon/blob/master/public/press-kit.zip"
},
{
"title": "Matternet",
@@ -1480,6 +1500,11 @@
"hex": "764ABC",
"source": "https://github.com/reactjs/redux/tree/master/logo"
},
+ {
+ "title": "Renren",
+ "hex": "217DC6",
+ "source": "https://seeklogo.com/vector-logo/184137/renren-inc"
+ },
{
"title": "ReverbNation",
"hex": "E43526",
diff --git a/icons/castorama.svg b/icons/castorama.svg
new file mode 100644
index 00000000..420ca4bf
--- /dev/null
+++ b/icons/castorama.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/envato.svg b/icons/envato.svg
new file mode 100644
index 00000000..a0aef97e
--- /dev/null
+++ b/icons/envato.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/go.svg b/icons/go.svg
new file mode 100644
index 00000000..8f66cb0b
--- /dev/null
+++ b/icons/go.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/java.svg b/icons/java.svg
new file mode 100644
index 00000000..fc2530d1
--- /dev/null
+++ b/icons/java.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/icons/mastodon.svg b/icons/mastodon.svg
index 74740484..fe7e5074 100644
--- a/icons/mastodon.svg
+++ b/icons/mastodon.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/icons/renren.svg b/icons/renren.svg
new file mode 100644
index 00000000..0f38a0ac
--- /dev/null
+++ b/icons/renren.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/index.js b/index.js
deleted file mode 100644
index 9d40cefa..00000000
--- a/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-const dataFile = './_data/simple-icons.json';
-const data = require(dataFile);
-const fs = require('fs');
-
-const icons = {};
-
-data.icons.forEach(i => {
- const filename = i.title.toLowerCase()
- .replace(/\+/g, "plus")
- .replace(/^\./, "dot-")
- .replace(/\.$/, "-dot")
- .replace(/\./g, "-dot-")
- .replace(/[ !’]/g, '');
- i.svg = fs.readFileSync(`${__dirname}/icons/${filename}.svg`, 'utf8');
- icons[i.title] = i
-});
-
-module.exports = icons;
diff --git a/package.json b/package.json
index a4e86bbe..4cdec28f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "simple-icons",
- "version": "1.8.4",
+ "version": "1.8.5",
"description": "SVG icons for popular brands https://simpleicons.org",
"homepage": "https://www.simpleicons.org",
"keywords": [
@@ -23,6 +23,8 @@
},
"scripts": {
"jsonlint": "jsonlint _data/simple-icons.json -q -V .jsonlintschema",
- "svglint": "svglint icons/* --ci"
+ "svglint": "svglint icons/* --ci",
+ "prepublishOnly": "node scripts/prepublish.js",
+ "postpublish": "rm icons/*.js index.js"
}
}
diff --git a/scripts/prepublish.js b/scripts/prepublish.js
new file mode 100755
index 00000000..00c0e998
--- /dev/null
+++ b/scripts/prepublish.js
@@ -0,0 +1,31 @@
+#!/usr/bin/env node
+/**
+ * @fileoverview
+ * Compiles our icons into static .js files that can be imported in the browser
+ * and are tree-shakeable.
+ * The static .js files go in icons/{filename}.js.
+ * Also generates an index.js that exports all icons by title, but is not tree-shakeable
+ */
+
+const dataFile = "../_data/simple-icons.json";
+const indexFile = `${__dirname}/../index.js`;
+const iconsDir = `${__dirname}/../icons`;
+const data = require(dataFile);
+const fs = require("fs");
+
+const { titleToFilename } = require("./utils");
+
+const icons = {};
+data.icons.forEach(icon => {
+ const filename = titleToFilename(icon.title);
+ icon.svg = fs.readFileSync(`${iconsDir}/${filename}.svg`, "utf8");
+ icons[icon.title] = icon;
+ // write the static .js file for the icon
+ fs.writeFileSync(
+ `${iconsDir}/${filename}.js`,
+ `module.exports=${JSON.stringify(icon)};`
+ );
+});
+
+// write our generic index.js
+fs.writeFileSync(indexFile, `module.exports=${JSON.stringify(icons)};`);
diff --git a/scripts/utils.js b/scripts/utils.js
new file mode 100644
index 00000000..9cd21c9e
--- /dev/null
+++ b/scripts/utils.js
@@ -0,0 +1,14 @@
+module.exports = {
+ /**
+ * Converts a brand title into a filename (not a full path)
+ * @param {String} title The title to convert
+ */
+ titleToFilename: title => (
+ title.toLowerCase()
+ .replace(/\+/g, "plus")
+ .replace(/^\./, "dot-")
+ .replace(/\.$/, "-dot")
+ .replace(/\./g, "-dot-")
+ .replace(/[ !’]/g, "")
+ )
+}