Skip to content

Commit

Permalink
uglify bundle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoulM committed Feb 5, 2018
1 parent 469a335 commit 2f9e1f1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
33 changes: 33 additions & 0 deletions gulp/tasks/bundleJs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Created by shoulm on 05/02/2018.
*/
var gulp = require('gulp');
const webpackStream= require('webpack-stream');
const webpack= require('webpack-stream').webpack;
const UglifyJsPlugin= require('uglifyjs-webpack-plugin');
const path= require('path');

gulp.task('bundle-js', function() {
return bundleJs();
});

function bundleJs(){
let bundleConfig={
entry: './primo-explore/www/renderer.js',
resolve:{
extensions: ['.js']
},
output:{
path: path.resolve('./primo-explore/www/'),
filename: 'bundle.js'
},
target: 'web',
devtool: 'source-map',
plugins: [new UglifyJsPlugin({sourceMap: true})]
};

return webpackStream(bundleConfig);
}



28 changes: 1 addition & 27 deletions gulp/tasks/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const utils= require('./utils/utils');
const npmi= require('npmi');
const buildCustomJs= require('./buildCustomJs');

gulp.task('serve', function() {
gulp.task('serve', ['bundle-js'], function() {
//1. serve with default settings
/* var server = gls.static(); //equals to gls.static('public', 3000);
server.start();*/

//2. serve at custom port
buildByBrowserify();

if (gulp.tasks.run) {
gulp.start('run')
Expand Down Expand Up @@ -196,28 +195,3 @@ function buildByBrowserify() {
.bundle()
.pipe(fs.createWriteStream('./primo-explore/www/bundle.js'));
}


// function getUserId(req){
// var ip= req.headers['x-forwarded-for'] || req.connection.remoteAddress;
// var userAgent= req.headers['user-agent'] || '';
// var userId= ip + userAgent;
// userId= userId.replace(/[^\d\w]/g, ''); //sanitize user id since it is user as a folder name
// return userId;
// }
//
// function getUserCustomDir(userId){
// return `primo-explore/custom/${userId}`;
// }
//
// function promiseSerial(funcs, param) {
// return funcs.reduce((promise, func) =>
// promise.then(result => func(param).then(Array.prototype.concat.bind(result))),
// Promise.resolve([]));
// }
//
// module.exports={
// promiseSerial: promiseSerial,
// getUserId: getUserId,
// getUserCustomDir: getUserCustomDir
// }
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"shelljs": "0.6.0",
"shorthash": "0.0.2",
"tar-fs": "1.13.0",
"unzip": "^0.1.11"
"uglifyjs-webpack-plugin": "^1.1.8",
"unzip": "^0.1.11",
"webpack-stream": "^4.0.0"
},
"engines": {
"node": ">=4.2"
Expand Down

0 comments on commit 2f9e1f1

Please sign in to comment.