Commit f8c6a2dc authored by Mauro Pompilio's avatar Mauro Pompilio

Dev and production build tasks and S3 deployment

parent 91d3e54e
......@@ -2,5 +2,6 @@
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
todo.md
\ No newline at end of file
todo.md
*.swp
dist/*
This diff is collapsed.
This diff is collapsed.
......@@ -13,7 +13,7 @@
room: 'marionettejs/backbone.marionette'
};
</script>
<script src="../../dist/sidecar.js" async defer></script>
<script src="https://sidecar.gitter.im/js/sidecar.v0.js" async defer></script>
</body>
</html>
......
var gulp = require('gulp');
var gutil = require('gulp-util');
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
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('compress', ['webpack:build'], 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) {
var major = manifest.version.split('.')[0];
var params = {
localFile: './dist/sidecar.js.gz',
s3Params: {
Bucket: 'sidecar.gitter.im',
Key: 'js/sidecar.v' + major + '.js',
CacheControl: 'public, max-age=0, no-cache',
ContentType: 'application/javascript',
ContentEncoding: 'gzip',
ACL: 'public-read'
}
};
var S3Client = S3.createClient({
s3Options: {
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET
},
});
var uploader = S3Client.uploadFile(params);
uploader.on('error', function (err) {
gutil.log(err.stack);
done(err);
});
uploader.on('end', function(metadata) {
done();
});
});
{
"name": "gitter-sidecar",
"version": "0.2.4",
"description": "",
"description": "An embeddable Gitter client.",
"main": "index.js",
"scripts": {
"gulp": "babel-node gulpfile.js",
"build-standalone": "webpack -p",
"build-standalone-dev": "webpack --watch --progress"
},
"author": "",
"license": "ISC",
"author": "The Gitter Team",
"license": "MIT",
"devDependencies": {
"autoprefixer": "^5.2.0",
"babel": "^5.8.20",
......@@ -17,6 +17,9 @@
"babel-loader": "^5.3.2",
"css-loader": "^0.16.0",
"csswring": "^3.0.5",
"gulp": "^3.9.0",
"gulp-gzip": "^1.2.0",
"gulp-util": "^3.0.6",
"postcss": "^4.1.16",
"postcss-css-variables": "^0.4.0",
"postcss-loader": "^0.5.1",
......@@ -27,6 +30,7 @@
},
"dependencies": {
"es6-promise": "^3.0.2",
"object-assign": "^3.0.0"
"object-assign": "^3.0.0",
"s3": "^4.4.0"
}
}
......@@ -195,4 +195,4 @@
}
}
}
\ No newline at end of file
}
......@@ -30,7 +30,6 @@ module.exports = {
library: 'sidecar',
libraryTarget: 'umd'
},
devtool: 'source-map',
module: {
loaders: [
{
......@@ -44,6 +43,7 @@ module.exports = {
}
]
},
plugins: [],
postcss: function () {
return [
nested(),
......
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