Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
webpack build for browser step added | build for npm step added (#9)
Browse files Browse the repository at this point in the history
* webpack build for browser step added | build for npm step added

* package

* added babel-plugin module to package for travis
  • Loading branch information
cosmocochrane1 authored and af-inet committed May 16, 2017
1 parent 8f17145 commit 4e3fc97
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 35 deletions.
5 changes: 3 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["es2015"]
}
"presets": ["es2015"],
"plugins": ["babel-plugin-add-module-exports"]
}
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"no-mixed-spaces-and-tabs": 1,
"eqeqeq": 1,
"no-console": 0,
"camelcase": 1,
"camelcase": 0,
"comma-dangle": 2,
"quotes": 0
}
Expand Down
8 changes: 8 additions & 0 deletions build_for_browser/GphApiClient.min.js

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ var gulp = require("gulp");
var eslint = require("gulp-eslint");
var prettify = require('gulp-jsbeautifier');

function lint(){
return gulp
.src("./**/*.js")
.pipe(eslint())
.pipe(eslint.format());
}

gulp.task('prettify', function() {
gulp.src(['./src/**/*.js'])
Expand All @@ -23,13 +17,13 @@ gulp.task('prettify', function() {
.pipe(gulp.dest('./src'));
});

gulp.task("lint", lint);

gulp.task("watch", ["default"], function() {
gulp.watch("./src/**/*.js", ["lint"]);
});
gulp.task("lint", function(){
gulp.src("./src/**/*.js")
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})

//build this for npm


gulp.task("default", ["lint", "prettify"]);
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"name": "@cosmocochrane/giphy-web-sdk-core",
"version": "1.0.14",
"version": "1.0.16",
"description": "",
"main": "index.js",
"scripts": {
"test": "npm run compile && mocha --compilers js:babel-core/register",
"compile": "babel -d lib/ src/",
"lint": "gulp default"
"test": "babel -d lib/ src/ && mocha --compilers js:babel-core/register",
"lint": "gulp default",
"build_for_npm": "gulp; babel -d lib/ src/",
"build_for_browser": "WEBPACK_ENV=build webpack"
},
"author": "",
"author": "Cosmo Cochrane",
"license": "ISC",
"dependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"es6-promise": "^4.1.0",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"promise": "^7.1.1"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"gulp": "^3.9.1",
"chai": "^3.5.0",
"gulp-eslint": "^3.0.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"mocha": "^3.3.0",
"babel-core": "^6.24.1",
"gulp-jsbeautifier": "^2.1.0"
"chai": "^3.5.0",
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1",
"gulp-jsbeautifier": "^2.1.0",
"mocha": "^3.3.0"
}
}
2 changes: 1 addition & 1 deletion src/handlers/RequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function RequestHandler(vals, endpoint, cb) {
method: args.method,
headers: {
"Content-Type": "application/json"
},
}
}).then((response) => { //calling the end function will send the actual request
if (canceled === true) {
return
Expand Down
1 change: 0 additions & 1 deletion src/handlers/ResponseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@



var _ = require('lodash');
var responseFormatter = require('../utils/responseFormatter');

//handle status code and resolve/reject promise
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var Image = function(data, id, rendition_type) {
mp4_url: data.mp4 ? data.mp4 : null,
mp4_size: data.mp4_size ? data.mp4_size : null,
webp_url: data.webp_url ? data.webp_url : null,
webp_size: data.webp_size ? data.webp_size : null,
webp_size: data.webp_size ? data.webp_size : null
})
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/

var Images = require('./Images');
var Image = require('./Image');
var User = require('./User');

var Media = function(data) {
Expand Down
5 changes: 0 additions & 5 deletions src/utils/responseFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ function responseFormatter(data, endpoint) {
height: data.fixed_height_small_height,
width: data.fixed_height_small_width
},
fixed_height_downsampled: {
gif_url: data.fixed_height_small_url,
height: data.fixed_height_small_height,
width: data.fixed_height_small_width
},
fixed_width_small: {
gif_url: data.fixed_width_small_url,
height: data.fixed_width_small_height,
Expand Down
54 changes: 54 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// webpack.config.js

var webpack = require('webpack');
var path = require('path');
var libraryName = 'library';
var outputFile = libraryName + '.js';

var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var env = process.env.WEBPACK_ENV;

var libraryName = 'GphApiClient';
var plugins = [];
var outputFile;

if (env === 'build') {
plugins.push(new UglifyJsPlugin({ minimize: true }));
outputFile = libraryName + '.min.js';
} else {
outputFile = libraryName + '.js';
}

module.exports = {
entry: __dirname + '/src/GphApiClient.js',
devtool: 'source-map',
output: {
path: __dirname + '/build_for_browser',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
loaders: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.jsx|\.js)$/,
loader: "eslint-loader",
exclude: /node_modules/
}
]
},
plugins: plugins,
resolve: {
modules: [
path.join(__dirname, "src"),
"node_modules"
]
}
};

0 comments on commit 4e3fc97

Please sign in to comment.