Commit 52fc0ac6 authored by Mauro Pompilio's avatar Mauro Pompilio

Less code is better code

parent f8c6a2dc
......@@ -6,72 +6,17 @@ var gzip = require('gulp-gzip');
var S3 = require('s3');
var manifest = require('./package.json');
// Default Task
gulp.task('default', ['build-dev']);
// Development build
gulp.task('build-dev', ['webpack:build-dev'], function() {
gulp.watch(['src/**/*'], ['webpack:build-dev']);
});
gulp.task('webpack:build-dev', function(callback) {
// modify some webpack config options
var myDevConfig = Object.create(webpackConfig);
myDevConfig.devtool = 'sourcemap';
myDevConfig.debug = true;
// create a single instance of the compiler to allow caching
var devCompiler = webpack(myDevConfig);
// run webpack
devCompiler.run(function(err, stats) {
if(err) throw new gutil.PluginError('webpack:build-dev', err);
gutil.log('[webpack:build-dev]', stats.toString({
colors: true
}));
callback();
});
});
// Production build
gulp.task('build', ['webpack:build']);
gulp.task('webpack:build', function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.plugins = myConfig.plugins.concat(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
// run webpack
webpack(myConfig, function(err, stats) {
if(err) throw new gutil.PluginError('webpack:build', err);
gutil.log('[webpack:build]', stats.toString({
colors: true
}));
callback();
});
});
// Deployment tasks
gulp.task('default', ['deploy']);
gulp.task('deploy', ['compress_assets', 'upload_to_s3']);
gulp.task('compress', ['webpack:build'], function() {
gulp.task('compress_assets', function() {
return gulp.src(['dist/**/*.{css,js,ttf,svg}'], { base: 'dist/' })
.pipe(gzip({ append: true, gzipOptions: { level: 9 } }))
.pipe(gulp.dest('dist/'));
});
gulp.task('release', ['compress'], function(done) {
gulp.task('upload_to_s3', ['compress_assets'], function(done) {
var major = manifest.version.split('.')[0];
var params = {
......
......@@ -4,9 +4,8 @@
"description": "An embeddable Gitter client.",
"main": "index.js",
"scripts": {
"gulp": "babel-node gulpfile.js",
"build-standalone": "webpack -p",
"build-standalone-dev": "webpack --watch --progress"
"build": "webpack --watch --progress",
"release": "webpack -p && gulp deploy"
},
"author": "The Gitter Team",
"license": "MIT",
......@@ -26,11 +25,11 @@
"postcss-nested": "^0.3.2",
"postcss-plugin-context": "^1.2.0",
"style-loader": "^0.12.3",
"webpack": "^1.10.5"
"webpack": "^1.10.5",
"s3": "^4.4.0"
},
"dependencies": {
"es6-promise": "^3.0.2",
"object-assign": "^3.0.0",
"s3": "^4.4.0"
"object-assign": "^3.0.0"
}
}
......@@ -30,6 +30,7 @@ module.exports = {
library: 'sidecar',
libraryTarget: 'umd'
},
devtool: 'sourcemap',
module: {
loaders: [
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment