Add JS and CSS minify.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-20 16:05:52 -04:00
parent 267c6483b5
commit 3d8ea65bf9
3 changed files with 52 additions and 4 deletions

View File

@ -7,15 +7,15 @@
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}{% endblock %} | Baby Blotter</title>
<link rel="stylesheet" href="{% static "babyblotter/css/vendor.css" %}" />
<link rel="stylesheet" href="{% static "babyblotter/css/vendor.min.css" %}" />
</head>
<body style="padding-top: 5rem;">
{% block nav %}{% endblock %}
{% block page %}{% endblock %}
<script src="{% static "babyblotter/js/vendor.js" %}"></script>
<script src="{% static "babyblotter/js/app.js" %}"></script>
<script src="{% static "babyblotter/js/vendor.min.js" %}"></script>
<script src="{% static "babyblotter/js/app.min.js" %}"></script>
{% block javascript %}{% endblock %}
</body>
</html>

View File

@ -1,5 +1,9 @@
var gulp = require('gulp');
var pump = require('pump');
var concat = require('gulp-concat');
var csso = require('gulp-csso');
var uglify = require('gulp-uglify');
/* APP FILES */
@ -49,6 +53,47 @@ gulp.task('vendor:fonts', function() {
gulp.task('vendor', ['vendor:styles', 'vendor:scripts', 'vendor:fonts']);
/* COMPRESSION */
gulp.task('compress:app:scripts', function (cb) {
pump([
gulp.src('babyblotter/static/babyblotter/js/app.js'),
concat('app.min.js'),
uglify(),
gulp.dest('babyblotter/static/babyblotter/js/')
],
cb
);
});
gulp.task('compress:vendor:scripts', function (cb) {
pump([
gulp.src('babyblotter/static/babyblotter/js/vendor.js'),
concat('vendor.min.js'),
uglify(),
gulp.dest('babyblotter/static/babyblotter/js/')
],
cb
);
});
gulp.task('compress:vendor:css', function (cb) {
pump([
gulp.src('babyblotter/static/babyblotter/css/vendor.css'),
concat('vendor.min.css'),
csso(),
gulp.dest('babyblotter/static/babyblotter/css/')
],
cb
);
});
gulp.task('compress', [
'compress:app:scripts',
'compress:vendor:scripts',
'compress:vendor:css'
]);
/* DEFAULT */
gulp.task('default', ['vendor', 'app']);
gulp.task('default', ['vendor', 'app', 'compress']);

View File

@ -7,9 +7,12 @@
"font-awesome": "^4.7.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-csso": "^3.0.0",
"gulp-uglify": "^3.0.0",
"jquery": "^3.2.1",
"moment": "^2.18.1",
"popper.js": "^1.12.3",
"pump": "^1.0.2",
"tempusdominus-bootstrap-4": "^5.0.0-alpha9"
}
}