-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (85 loc) · 2.47 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
/*
* Gulp dependencies
*/
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
const minify = require('gulp-minify');
const imagemin = require('gulp-imagemin');
const webpack = require('webpack-stream');
/*
* Configuration
*/
const config = {
source: './assets',
output: './public',
};
gulp.task('scss', () =>
gulp.src(config.source + '/scss/*.scss')
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe(cleanCSS())
.pipe(gulp.dest(config.output + '/css'))
);
/*gulp.task('js', () =>
gulp.src(config.source + '/js/!**!/!*.js')
.pipe(plumber())
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(minify({
ext:{
src:'-debug.js',
min:'.min.js'
}
}))
.pipe(gulp.dest(config.output + '/js'))
);*/
gulp.task('js', () =>
gulp.src(config.source + '/js/main.js')
.pipe(plumber())
.pipe(webpack({
mode: 'development',
output: {
filename: 'app.js',
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['@babel/preset-env']
}
}
]
}
}))
.pipe(minify({
ext:{
src:'.debug.js',
min:'.min.js'
}
}))
.pipe(gulp.dest(config.output + '/js'))
);
gulp.task('images', () =>
gulp.src(config.source + '/images/*')
.pipe(imagemin())
.pipe(gulp.dest(config.output + '/images'))
);
gulp.task('favicon', () =>
gulp.src(config.source + '/favicon/*')
.pipe(gulp.dest(config.output + '/favicon'))
);
gulp.task('watch', ['js', 'scss'], () => {
gulp.watch(config.source + '/scss/**/*.scss', ['scss']);
gulp.watch(config.source + '/js/**/*.js', ['js']);
});
gulp.task('build', ['scss', 'js', 'images', 'favicon']);
gulp.task('default', ['build', 'watch']);