-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·95 lines (79 loc) · 2.61 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Gulp
*
* Implements
* 1. Live reloads browser with BrowserSync.
* 2. CSS: Sass to Css conversion, Autoprefixing, Sourcemaps,
* CSS minification, and Merge Media Queries.
*
* @uthor Mystro Ken <[email protected]>
* @version 1.0
*/
// Style configuration.
var style_src = './assets/scss/main.scss';
var style_dest = './assets/css/';
// Watch files paths.
var style_watch_files = './assets/scss/**/*.scss';
// Browsers we care about for autoprefixing.
// Browserlist https://github.com/ai/browserslist
const AUTOPREFIXER_BROWSERS = [
'last 2 version',
'> 1%',
'ie >= 9',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4',
'bb >= 10'
];
// STOP Editing project variables
/**
* Load Plugins
*
*/
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifycss = require('gulp-uglifycss');
var autoprefixer = require('gulp-autoprefixer');
var mmq = require('gulp-merge-media-queries');
var rename = require('gulp-rename'); // Renames files E.g. style.css -> style.min.css
var lineec = require('gulp-line-ending-corrector'); // Consistent Line Endings for non UNIX systems. Gulp Plugin for Line Ending Corrector (A utility that makes sure your files have consistent line endings)
var filter = require('gulp-filter'); // Enables you to work on a subset of the original files by filtering them using globbing.
var sourcemaps = require('gulp-sourcemaps'); // Maps code in a compressed file (E.g. style.css) back to it’s original position in a source file (E.g. structure.scss, which was later combined with other css files to generate style.css)
var notify = require('gulp-notify'); // Sends message notification to you
/**
* Task: `styles`
*/
gulp.task('styles', function(){
gulp.src(style_src)
.pipe(sourcemaps.init())
.pipe(sass({
errorLogToConsole: true,
outputStyle: 'compact',
precision: 10
}))
.on('error', console.error.bind(console))
.pipe(sourcemaps.write({includeContent: false}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(sourcemaps.write('./'))
.pipe(lineec())
.pipe(gulp.dest(style_dest))
.pipe(filter('**/**/*.css'))
.pipe(mmq({log: true}))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({maxLineLen: 10}))
.pipe(lineec())
.pipe(gulp.dest(style_dest))
.pipe(filter('**/**/*.css'))
.pipe(notify({message: 'TASK: "styles" completed!', onLast: true}))
});
/**
* Watch Tasks.
*/
gulp.task('default', ['styles'], function(){
gulp.watch(style_watch_files, ['styles']);
});