60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const gulp = require('gulp');
|
|
const babel = require('gulp-babel');
|
|
const eslint = require('gulp-eslint');
|
|
const sass = require('gulp-sass');
|
|
const sourcemaps = require('gulp-sourcemaps');
|
|
const wait = require('gulp-wait');
|
|
|
|
const paths = ['src/**/*.js'];
|
|
const cssPaths = {
|
|
src: './sass/**/*.scss',
|
|
dest: './public/css',
|
|
};
|
|
|
|
gulp.task('default', ['build']);
|
|
|
|
gulp.task('watch', ['build'], () => {
|
|
gulp.watch(paths, ['build']);
|
|
});
|
|
|
|
gulp.task('build', ['sass', 'babel']);
|
|
|
|
gulp.task('lint', () => {
|
|
gulp.src(paths)
|
|
.pipe(eslint())
|
|
.pipe(eslint.format())
|
|
.pipe(eslint.failAfterError());
|
|
});
|
|
|
|
gulp.task('sass', () =>
|
|
gulp.src(cssPaths.src)
|
|
.pipe(wait(100))
|
|
.pipe(sourcemaps.init())
|
|
.pipe(sass({
|
|
includePaths: './node_modules',
|
|
outputStyle: 'compressed',
|
|
}).on('error', sass.logError))
|
|
.pipe(sourcemaps.write('./maps'))
|
|
.pipe(gulp.dest(cssPaths.dest)));
|
|
|
|
gulp.task('sass:watch', () => {
|
|
gulp.watch(['./sass/**/*.scss', './sass/**/*.sass'], ['sass']);
|
|
});
|
|
|
|
gulp.task('sass:prod', () =>
|
|
gulp.src(cssPaths.src)
|
|
.pipe(sass({
|
|
includePaths: './node_modules',
|
|
outputStyle: 'compressed',
|
|
}).on('error', sass.logError))
|
|
.pipe(gulp.dest(cssPaths.dest)));
|
|
|
|
|
|
gulp.task('babel', () => {
|
|
gulp.src(paths)
|
|
.pipe(babel())
|
|
.pipe(gulp.dest('build'));
|
|
});
|