Fix and minify JavaScript
This commit is contained in:
parent
18300b2470
commit
8bf421adba
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
/output_*/
|
/output_*/
|
||||||
/source/assets/css/
|
/source/assets/css/
|
||||||
/source/assets/fonts/
|
/source/assets/fonts/
|
||||||
|
/source/assets/js/
|
||||||
/.sculpin/
|
/.sculpin/
|
||||||
/vendor/
|
/vendor/
|
||||||
.sass-cache/
|
.sass-cache/
|
||||||
|
|
22
gulpfile.js
22
gulpfile.js
|
@ -32,6 +32,16 @@ app.copy = function(srcFiles, outputDir) {
|
||||||
.pipe(gulp.dest(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 () {
|
gulp.task('fonts', function () {
|
||||||
// Copy fonts from bower_components into source/asset/fonts.
|
// Copy fonts from bower_components into source/asset/fonts.
|
||||||
app.copy(config.bowerDir + '/font-awesome/fonts/*', config.assetsDir + '/fonts');
|
app.copy(config.bowerDir + '/font-awesome/fonts/*', config.assetsDir + '/fonts');
|
||||||
|
@ -41,7 +51,14 @@ gulp.task('styles', function () {
|
||||||
app.addStyle([
|
app.addStyle([
|
||||||
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
||||||
'./sass/styles.scss'
|
'./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 () {
|
gulp.task('images', function () {
|
||||||
|
@ -59,10 +76,11 @@ gulp.task('watch', function () {
|
||||||
gulp.task('clean', function () {
|
gulp.task('clean', function () {
|
||||||
del.sync(config.assetsDir + '/css');
|
del.sync(config.assetsDir + '/css');
|
||||||
del.sync(config.assetsDir + '/fonts');
|
del.sync(config.assetsDir + '/fonts');
|
||||||
|
del.sync(config.assetsDir + '/js');
|
||||||
del.sync('./output_*/assets/css/*');
|
del.sync('./output_*/assets/css/*');
|
||||||
del.sync('./output_*/assets/fonts/*');
|
del.sync('./output_*/assets/fonts/*');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build', ['clean', 'styles', 'fonts']);
|
gulp.task('build', ['clean', 'styles', 'scripts', 'fonts']);
|
||||||
|
|
||||||
gulp.task('default', ['build', 'watch']);
|
gulp.task('default', ['build', 'watch']);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"gulp-plumber": "^1.0.1",
|
"gulp-plumber": "^1.0.1",
|
||||||
"gulp-sass": "^2.1.1",
|
"gulp-sass": "^2.1.1",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
|
"gulp-uglify": "^1.5.1",
|
||||||
"gulp-util": "^3.0.7"
|
"gulp-util": "^3.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ DEPLOY_USER=deployment
|
||||||
DEPLOY_HOST=www.oliverdavies.uk
|
DEPLOY_HOST=www.oliverdavies.uk
|
||||||
DEPLOY_PATH=/var/www/oliverdavies/public
|
DEPLOY_PATH=/var/www/oliverdavies/public
|
||||||
|
|
||||||
# Rebuild stylesheets.
|
# Rebuild assets.
|
||||||
gulp styles --production
|
gulp build --production
|
||||||
|
|
||||||
./vendor/bin/sculpin generate --env=${ENV} --clean --no-interaction
|
./vendor/bin/sculpin generate --env=${ENV} --clean --no-interaction
|
||||||
if [ $? -ne 0 ]; then echo "Could not generate the site"; exit 1; fi
|
if [ $? -ne 0 ]; then echo "Could not generate the site"; exit 1; fi
|
||||||
|
|
|
@ -90,8 +90,7 @@
|
||||||
{% include('meetups') %}
|
{% include('meetups') %}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="{{ site.url }}/components/jquery/jquery.min.js"></script>
|
<script src="{{ site.url }}/assets/js/all.js"></script>
|
||||||
<script src="{{ site.url }}/components/bootstrap/js/bootstrap.min.js"></script>
|
|
||||||
|
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue