Skip to content

Commit

Permalink
Removed emoji-data as peer dep, too big for npm, and also github dep …
Browse files Browse the repository at this point in the history
…not working well if package.json exists, downloading postinstall
  • Loading branch information
unimonkiez committed May 4, 2016
1 parent c263ed4 commit 360e11d
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
lib/
emoji-data/
npm-debug.log
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
src/
bin/
!bin/install.js
resources/
dist/
example/
emoji-data/
.editorconfig
.eslintignore
.eslintrc
Expand Down
8 changes: 8 additions & 0 deletions bin/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ecmaFeatures": {
"modules": false
},
"rules": {
"no-console": 0
}
}
33 changes: 33 additions & 0 deletions bin/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require('fs');
const ghdownload = require('github-download');
const path = require('path');

const emojiDataPackageLocation = path.join(__dirname, '..', 'emoji-data');

fs.access(emojiDataPackageLocation, fs.F_OK, err => {
if (err) {
// Directory doesn't exist, download
ghdownload({
user: 'iamcal',
repo: 'emoji-data',
ref: 'master' // Waiting for pull request and then change to 'v2.4.1'
}, emojiDataPackageLocation)
.on('dir', dir => {
console.log(dir);
})
.on('file', file => {
console.log(file);
})
.on('zip', zipUrl => { //only emitted if Github API limit is reached and the zip file is downloaded
console.log(zipUrl);
})
.on('error', err => {
console.log(err);
})
.on('end', () => {
console.log('Finished downloading emoji-data');
});
} else {
console.log('emoji-data already downloaded, skipping download');
}
});
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script>hljs.initHighlightingOnLoad();</script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Poiret+One" rel="stylesheet" type="text/css">
</head>
<body>
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Add panel picker for emojis with different types of sets on your website. http://TimeToKnow.github.io/emoji-panel/",
"main": "lib/emoji-panel.js",
"scripts": {
"postinstall": "node ./bin/install.js",
"test": "eslint .",
"lib": "webpack --progress --config ./webpack.lib.config.js && rimraf ./lib/emoji-panel-*.js",
"build": "webpack --progress && rimraf ./dist/emoji-panel-*.js",
Expand All @@ -28,11 +29,12 @@
],
"author": "unimonkiez",
"license": "MIT",
"peerDependencies": {
"emoji-data": "git+https://github.com/iamcal/emoji-data.git#v2.4.1"
"dependencies": {
"github-download": "^0.4.0",
"path": "^0.12.7"
},
"devDependencies": {
"absurd": "^0.3.6",
"absurd": "^0.3.34",
"absurd-loader": "0.0.2",
"babel-eslint": "^6.0.2",
"babel-loader": "^6.2.4",
Expand All @@ -46,10 +48,11 @@
"html-webpack-plugin": "^2.15.0",
"json-loader": "^0.5.4",
"node-sass": "^3.4.2",
"path": "^0.12.7",
"raw-loader": "^0.5.1",
"replace-loader": "^0.1.0",
"rimraf": "^2.5.2",
"sass-loader": "^3.2.0",
"string-replace-webpack-plugin": "0.0.3",
"style-loader": "^0.13.1",
"webpack": "^1.12.15",
"webpack-dev-server": "^1.14.1"
Expand Down
2 changes: 1 addition & 1 deletion src/emoji.data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const emojiData = require('emoji-data');
const emojiData = require('../emoji-data');
const categoryDataMap = require('./map').categoryDataMap;

const sortedEmojiData = emojiData
Expand Down
2 changes: 1 addition & 1 deletion src/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getImageFileLocation = (imageSet, size) => {
imageSetStr = 'emojione';
break;
}
return `~emoji-data/sheet_${imageSetStr}_${sizeStr}.png`;
return `../../emoji-data/sheet_${imageSetStr}_${sizeStr}.png`;
};

const getBoolNameByImageSet = imageSet => {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = {
},
{
test: /\.(png|ttf)$/,
loader: 'file?name=./asset/[hash].[ext]'
loader: 'file?name=./asset/[name].[ext]'
}
]
},
Expand Down
5 changes: 3 additions & 2 deletions webpack.lib.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ Object.assign(webpackBaseConfig, {
}),
module: Object.assign(webpackBaseConfig.module, {
loaders: webpackBaseConfig.module.loaders
.filter(loaderObj => loaderObj.test.toString() !== /\.acss.js$/.toString()) // Remove loader to add it later wiht different loader
.filter(loaderObj => loaderObj.test.toString() !== /\.acss.js$/.toString()) // Remove loader to add it later with different loader
.concat(
{
test: /\.acss.js$/,
loader: ExtractTextPlugin.extract('style', 'raw!absurd') // Without css-loader so it won't resolve file imports, raw instead
// Without css-loader so it won't resolve file imports, raw instead, and replace emoji-data imports location
loader: ExtractTextPlugin.extract('style', 'raw!replace?flags=g&regex=\.\.\/\.\.\/emoji-data&sub=\.\.\/emoji-data!absurd')
}
)
})
Expand Down

0 comments on commit 360e11d

Please sign in to comment.