diff --git a/.gitignore b/.gitignore index 8adf4b01..be5fee93 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /output_*/ /source/assets/css/ /source/assets/fonts/ +/source/assets/js/ /.sculpin/ /vendor/ .sass-cache/ diff --git a/gulpfile.js b/gulpfile.js index 9f39310a..d655398b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,6 +32,16 @@ app.copy = function(srcFiles, outputDir) { .pipe(gulp.dest(outputDir)); }; +app.addScript = function(paths, filename) { + gulp.src(paths) + .pipe(plugins.plumber()) + .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.init())) + .pipe(plugins.concat(filename)) + .pipe(config.production ? plugins.uglify() : plugins.util.noop()) + .pipe(plugins.if(config.sourceMaps, plugins.sourcemaps.write('.'))) + .pipe(gulp.dest(config.assetsDir + '/js')) +} + gulp.task('fonts', function () { // Copy fonts from bower_components into source/asset/fonts. app.copy(config.bowerDir + '/font-awesome/fonts/*', config.assetsDir + '/fonts'); @@ -41,7 +51,14 @@ gulp.task('styles', function () { app.addStyle([ config.bowerDir + '/font-awesome/css/font-awesome.css', './sass/styles.scss' - ], 'all.css') + ], 'all.css'); +}); + +gulp.task('scripts', function () { + app.addScript([ + config.bowerDir + '/jquery/dist/jquery.js', + config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js' + ], 'all.js'); }); gulp.task('images', function () { @@ -59,10 +76,11 @@ gulp.task('watch', function () { gulp.task('clean', function () { del.sync(config.assetsDir + '/css'); del.sync(config.assetsDir + '/fonts'); + del.sync(config.assetsDir + '/js'); del.sync('./output_*/assets/css/*'); del.sync('./output_*/assets/fonts/*'); }); -gulp.task('build', ['clean', 'styles', 'fonts']); +gulp.task('build', ['clean', 'styles', 'scripts', 'fonts']); gulp.task('default', ['build', 'watch']); diff --git a/package.json b/package.json index 80d00ad8..26126d87 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "gulp-plumber": "^1.0.1", "gulp-sass": "^2.1.1", "gulp-sourcemaps": "^1.6.0", + "gulp-uglify": "^1.5.1", "gulp-util": "^3.0.7" } } diff --git a/publish.sh b/publish.sh index 9d04a4cf..4c56f71a 100755 --- a/publish.sh +++ b/publish.sh @@ -5,8 +5,8 @@ DEPLOY_USER=deployment DEPLOY_HOST=www.oliverdavies.uk DEPLOY_PATH=/var/www/oliverdavies/public -# Rebuild stylesheets. -gulp styles --production +# Rebuild assets. +gulp build --production ./vendor/bin/sculpin generate --env=${ENV} --clean --no-interaction if [ $? -ne 0 ]; then echo "Could not generate the site"; exit 1; fi diff --git a/source/_layouts/default.html.twig b/source/_layouts/default.html.twig index f345daf3..c375a6e4 100644 --- a/source/_layouts/default.html.twig +++ b/source/_layouts/default.html.twig @@ -90,8 +90,7 @@ {% include('meetups') %} - - + {% block scripts %}{% endblock %}