mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Add tasks to put code in production
This commit is contained in:
parent
a1bfbb8f86
commit
9f2019e168
23
gulpfile.js
23
gulpfile.js
@ -17,17 +17,22 @@ var _ = require('lodash');
|
|||||||
var eslint = require('gulp-eslint');
|
var eslint = require('gulp-eslint');
|
||||||
var argv = require('yargs').argv;
|
var argv = require('yargs').argv;
|
||||||
var server = require('./server.js').app;
|
var server = require('./server.js').app;
|
||||||
|
var minifyCss = require('gulp-minify-css');
|
||||||
|
var uglify = require('gulp-uglify');
|
||||||
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
bootstrapDir: './node_modules/bootstrap-sass'
|
bootstrapDir: './node_modules/bootstrap-sass'
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('build', function() {
|
gulp.task('build', ['js:build', 'sass:build', 'copy'], function() {
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('js:build', function() {
|
||||||
bundle(false);
|
bundle(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('serve', ['browser-sync', 'run-server', 'lint:watch', 'sass', 'sass:watch', 'copy'], function() {
|
gulp.task('serve', ['browser-sync', 'run-server', 'lint:watch', 'sass:build', 'sass:watch', 'copy'], function() {
|
||||||
bundle(true);
|
bundle(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -43,15 +48,16 @@ gulp.task('browser-sync', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('sass', function () {
|
gulp.task('sass:build', function () {
|
||||||
gulp.src('./sass/**/main.scss')
|
gulp.src('./sass/**/main.scss')
|
||||||
.pipe(sourcemaps.init())
|
.pipe(gulpif(!argv.production, sourcemaps.init()))
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: [
|
includePaths: [
|
||||||
config.bootstrapDir + '/assets/stylesheets'
|
config.bootstrapDir + '/assets/stylesheets'
|
||||||
]
|
]
|
||||||
}).on('error', sass.logError))
|
}).on('error', sass.logError))
|
||||||
.pipe(sourcemaps.write('./maps'))
|
.pipe(gulpif(!argv.production, sourcemaps.write('./maps')))
|
||||||
|
.pipe(gulpif(argv.production, minifyCss()))
|
||||||
.pipe(gulp.dest('./build/css'))
|
.pipe(gulp.dest('./build/css'))
|
||||||
.pipe(browserSync.stream());
|
.pipe(browserSync.stream());
|
||||||
});
|
});
|
||||||
@ -117,10 +123,11 @@ function bundle(watch) {
|
|||||||
.on('error', notify.onError('Error: <%= error.message %>'))
|
.on('error', notify.onError('Error: <%= error.message %>'))
|
||||||
.pipe(source('app.js'))
|
.pipe(source('app.js'))
|
||||||
.pipe(buffer())
|
.pipe(buffer())
|
||||||
.pipe(sourcemaps.init({
|
.pipe(gulpif(!argv.production, sourcemaps.init({
|
||||||
loadMaps: true
|
loadMaps: true
|
||||||
})) // loads map from browserify file
|
}))) // loads map from browserify file
|
||||||
.pipe(sourcemaps.write()) // writes .map file
|
.pipe(gulpif(!argv.production, sourcemaps.write())) // writes .map file
|
||||||
|
.pipe(gulpif(argv.production, uglify()))
|
||||||
.pipe(gulp.dest('./build/js'))
|
.pipe(gulp.dest('./build/js'))
|
||||||
.pipe(browserSync.stream());
|
.pipe(browserSync.stream());
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
"gulp-concat": "^2.5.2",
|
"gulp-concat": "^2.5.2",
|
||||||
"gulp-eslint": "^0.13.2",
|
"gulp-eslint": "^0.13.2",
|
||||||
"gulp-if": "^1.2.5",
|
"gulp-if": "^1.2.5",
|
||||||
|
"gulp-minify-css": "^1.1.6",
|
||||||
"gulp-notify": "^2.2.0",
|
"gulp-notify": "^2.2.0",
|
||||||
"gulp-sass": "^2.0.1",
|
"gulp-sass": "^2.0.1",
|
||||||
"gulp-sourcemaps": "^1.5.2",
|
"gulp-sourcemaps": "^1.5.2",
|
||||||
|
"gulp-uglify": "^1.2.0",
|
||||||
"gulp-util": "^3.0.4",
|
"gulp-util": "^3.0.4",
|
||||||
"jest-cli": "^0.4.0",
|
"jest-cli": "^0.4.0",
|
||||||
"lodash": "^3.9.3",
|
"lodash": "^3.9.3",
|
||||||
|
@ -10,7 +10,6 @@ app.get(/.*/, function(req, res) {
|
|||||||
res.sendFile(__dirname + '/index.html');
|
res.sendFile(__dirname + '/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
app.listen(process.env.PORT || 4000);
|
app.listen(process.env.PORT || 4000);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user