-
Notifications
You must be signed in to change notification settings - Fork 16
/
Gulpfile.js
54 lines (48 loc) · 1.83 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
var gulp = require('gulp'),
postcss = require('gulp-postcss'),
uglify = require('gulp-uglify'),
browserify = require('browserify'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
babelify = require('babelify'),
plumber = require('gulp-plumber'),
source = require('vinyl-source-stream'),
streamify = require('gulp-streamify'),
nano = require('gulp-cssnano'),
util = require('gulp-util'),
tailwindcss = require('tailwindcss');
var browserSync = require('browser-sync').create();
var paths = {
cssSource: 'resources/scss/',
jsSource: 'resources/js/',
destination: 'assets/'
};
gulp.task('styles', function () {
return gulp.src(paths.cssSource + 'main.scss')
.pipe(plumber())
.pipe(util.env.production ? sourcemaps.init() : util.noop())
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
tailwindcss('tailwind.js'),
require('autoprefixer'),
require('cssnano')
]))
.pipe(util.env.production ? nano({autoprefixer: false}) : util.noop())
.pipe(util.env.production ? sourcemaps.write('./') : util.noop())
.pipe(gulp.dest(paths.destination))
.pipe(util.env.production ? util.noop() : browserSync.stream({match: '**/*.css'}));
});
gulp.task('scripts', function () {
return browserify(paths.jsSource + 'app.js')
.transform(babelify, {presets: ["es2015"]})
.bundle()
.on('error', function (e) {
console.log(e.message);
this.emit('end');
})
.pipe(source('app.js'))
.pipe(util.env.production ? streamify(uglify()) : util.noop())
.pipe(gulp.dest(paths.destination));
});
gulp.watch(paths.cssSource + '**/*.scss', gulp.parallel('styles'));
gulp.task('default', gulp.parallel('styles', 'scripts'));