Skip to content

Commit

Permalink
Add gulpfile to minify and compress
Browse files Browse the repository at this point in the history
  • Loading branch information
rjcarneiro committed Oct 13, 2018
1 parent e0ce7b8 commit 602f2f7
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ Thumbs.db
#Ignore metadata created by OSX
.DS_Store
._*

# Ignore node stuff
package-lock.json
node_modules/
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PROJECT:

Naming variables definitions:
– Use camelCase for Liquid / Jekyll and Javascript's variables (and IDs)
– Use underscore separation for YMAL's variables
– Use underscore separation for YAML's variables
– Use hyphen to CSS classes, markdown files' titles, etc.

-----
Expand All @@ -17,3 +17,11 @@ How to create a new:
– Event: Go to my_collections/events/event-template.md and insert all the details of a new event (don't forget to save as the-name-of-the-event).
– Meeting venue: Go to data/meeting-venues.yml and create (or update) all the details of a new venue.
– Sponsor: Go to data/sponsors-list.yml and create (or update) all the details of a new sponsor.

## Installation

Use `npm install` to install all packages.

## Build

To create a new release just type `gulp` in the terminal.
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ exclude:
- Gemfile
- Gemfile.lock
- serve.sh
- package-lock.json
- package.json
- node_modules/
- gulpfile.js

show_drafts: false
future: false
Expand Down
81 changes: 81 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"use strict";

var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var del = require('del');
var gulp = require('gulp');
var htmlmin = require('gulp-htmlmin');
var runSequence = require('run-sequence');
var uglify = require('gulp-uglify');
var run = require('gulp-run');
var gutil = require('gulp-util');
var imagemin = require('gulp-imagemin');

var imagePattern = '/**/*.+(jpg|JPG|jpeg|JPEG|png|PNG|svg|SVG|gif|GIF|webp|WEBP|tif|TIF)';

var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];

var path = {
site: '_site',
css: '_site/css',
js: '_site/js',
img: '_site/img'
};

gulp.task('styles', function () {
return gulp.src(path.css + '/**/**.css')
.pipe(autoprefixer({
browsers: AUTOPREFIXER_BROWSERS
}))
.pipe(csso())
.pipe(gulp.dest(path.css));
});

gulp.task('scripts', function () {
return gulp.src(path.js + '/**/*.js')
.pipe(uglify())
.pipe(gulp.dest(path.js));
});

gulp.task('pages', function () {
return gulp.src([path.site + '/**/*.html'])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest(path.site));
});

gulp.task('clean', () => del([path.site]));

gulp.task('build', function () {
return gulp.src('')
.pipe(run('bundle exec jekyll build'))
.on('error', gutil.log);
});

gulp.task('images', function () {
return gulp.src(path.img + imagePattern)
.pipe(imagemin())
.pipe(gulp.dest(path.img));
});

gulp.task('default', ['clean'], function () {
runSequence(
'build',
'styles',
'scripts',
'pages',
'images'
);
});
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "netponto-org",
"version": "1.0.0",
"description": "Comunidade NetPonto",
"repository": {
"type": "git",
"url": "https://github.com/netponto/netponto.github.io.git"
},
"author": "Comunidade NetPonto",
"homepage": "https://netponto.github.io/",
"devDependencies": {
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^6.0.0",
"gulp-csso": "^3.0.1",
"gulp-htmlmin": "^5.0.1",
"gulp-run-command": "^0.0.9",
"gulp-sass": "^4.0.1",
"gulp-uglify": "^3.0.1",
"gulp-util": "^3.0.8",
"run-sequence": "^2.2.1",
"gulp-run": "^1.7.1",
"gulp-imagemin": "^4.1.0"
}
}
1 change: 1 addition & 0 deletions serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ bundle exec jekyll serve --port 4096 --watch --incremental --trace --config _con

echo "cleaning up..."
rm -Rf _site

0 comments on commit 602f2f7

Please sign in to comment.