chore(): minify css and js files

This commit is contained in:
kendo5731 2016-02-06 16:10:42 +01:00
parent b250023b85
commit 90fffad48a
7 changed files with 29 additions and 7 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
npm-debug.log
static/css/theme.css
static/css/theme.min.css
static/js/theme.js
static/js/theme.min.js
node_modules
static/fonts
!static/fonts/.gitkeep

View File

@ -6,7 +6,6 @@ A theme for [Hugo](https://gohugo.io/), inspired by Atom editor.
This repo is a work in progress, there is still work to do, contributions are welcome !
- Uglify CSS and Javascript
- Add integration with Disqus
- Add integration with Google Analytics
- Add a "Home" link in the top of the menu

View File

@ -1,24 +1,41 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('fonts', function() {
gulp.src('./node_modules/bootstrap-sass/assets/fonts/bootstrap/*')
.pipe(gulp.dest('./static/fonts'));
});
gulp.task('sass', function() {
return gulp.src("./static/css/theme.scss")
gulp.task('css', function() {
return gulp.src('./static/css/theme.scss')
.pipe(sass().on('error', handleError))
.pipe(gulp.dest('./static/css'))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./static/css'));
});
gulp.task('js', function() {
return gulp.src('./static/js/!(theme.js|theme.min.js)')
.pipe(concat('theme.js'))
.pipe(gulp.dest('./static/js'))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./static/js'));
});
gulp.task('watch', function() {
gulp.watch('./static/**/*.scss', ['sass']);
gulp.watch('./static/**/*.scss', ['css']);
gulp.watch('./static/**/*.js', ['js']);
});
gulp.task('default', function() {
gulp.start('fonts', 'sass');
gulp.start('fonts', 'css', 'js');
});
function handleError(err) {

View File

@ -1 +1 @@
<script src="js/theme.js" type="text/javascript"></script>
<script src="js/theme.min.js" type="text/javascript"></script>

View File

@ -10,4 +10,4 @@
<title>{{ .Title }}</title>
{{ .Hugo.Generator }}
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700" rel="stylesheet" type="text/css">
<link href="{{ .Site.BaseURL }}css/theme.css" rel="stylesheet" type="text/css">
<link href="{{ .Site.BaseURL }}css/theme.min.css" rel="stylesheet" type="text/css">

View File

@ -7,7 +7,11 @@
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.1",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7"
},
"scripts": {