-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
68 lines (52 loc) · 1.57 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var input = './development/scss/styles.scss';
var output = './public/css';
var inputJs = './development/js/*.js';
var outputJs = './public/js';
var sourcemaps = require('gulp-sourcemaps')
const autoprefixer = require('gulp-autoprefixer');
const concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
// -------------------------------
// default gulp task
gulp.task('default', function () {
// watch for JS changes
gulp.watch(input, function () {
gulp.run('sass');
});
// watch for SCSS changes
gulp.watch(inputJs, function () {
gulp.run('build-js');
});
});
// -------------------------------
gulp.task('sass', function () {
return gulp
// Find all `.scss` files from the `stylesheets/` folder
.src(input)
// Run Sass on those files
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(cleanCSS())
.pipe(concat('samen.css'))
.pipe(sourcemaps.write('./'))
// Write the resulting CSS in the output folder
.pipe(gulp.dest(output));
});
// -------------------------------
gulp.task('build-js', function () {
return gulp.src(inputJs)
.pipe(sourcemaps.init())
.pipe(concat('samen.js'))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(outputJs));
});