-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
70 lines (63 loc) · 1.79 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
const gulp = require('gulp');
const postcss = require('gulp-postcss');
const cssImport = require('postcss-import');
const postcssPresetEnv = require('postcss-preset-env');
const postcssNested = require('postcss-nested');
const postcssCustomMedia = require('postcss-custom-media');
const rollup = require('gulp-rollup');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('rollup-plugin-babel');
const minify = require('gulp-minify');
gulp.task('css', () =>
gulp
.src(['./src/assets/css/main.css'])
.pipe(
postcss([
postcssCustomMedia(),
cssImport(),
postcssNested(),
postcssPresetEnv({
stage: 2,
features: {
'nesting-rules': true,
},
}),
])
)
.pipe(gulp.dest('./dist/assets/css'))
);
gulp.task('js', () =>
gulp
.src(['./src/assets/js/*'])
.pipe(sourcemaps.init())
.pipe(
rollup({
allowRealFiles: true,
input: './src/assets/js/main.js',
output: {
format: 'cjs',
},
plugins: [
babel({
presets: [['@babel/preset-env']],
}),
],
})
)
.pipe(minify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/assets/js'))
);
gulp.task('fonts', () =>
gulp.src(['./src/assets/fonts/*']).pipe(gulp.dest('./dist/assets/fonts'))
);
gulp.task('images', () =>
gulp.src(['./src/assets/img/*']).pipe(gulp.dest('./dist/assets/img'))
);
gulp.task('watch', function () {
gulp.watch('./src/assets/**/*.css', gulp.series('css'));
gulp.watch('./src/assets/fonts/*', gulp.series('fonts'));
gulp.watch('./src/assets/img/*', gulp.series('images'));
gulp.watch('./src/assets/js/*.js', gulp.series('js'));
});
gulp.task('default', gulp.parallel('css', 'fonts', 'js', 'images'));