-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (60 loc) · 1.96 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
"use strict";
// Plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const gulp = require('gulp');
// gulp plugins and utils
const livereload = require('gulp-livereload');
// var sourcemaps = require('gulp-sourcemaps');
const sass = require('gulp-sass');
const rename = require('gulp-rename');
const plumber = require("gulp-plumber");
const concat = require('gulp-concat');
const webpack = require("webpack");
const webpackconfig = require("./webpack.config.js");
const webpackstream = require("webpack-stream");
const postcss = require('gulp-postcss');
const custom_media = require('postcss-custom-media');
function css() {
return gulp
.src('assets/sass/*.scss')
.pipe(plumber())
.pipe(sass({ outputStyle: "expanded" }))
// .pipe(sass().on('error', sass.logError))
.pipe(concat('styles.css'))
.pipe(postcss([custom_media(),autoprefixer()]))
.pipe(gulp.dest('assets/built/'))
// .pipe(browsersync.stream())
}
function scripts() {
return (
gulp
.src(['./assets/js/vendor/*.js', './assets/js/lib/*.js', './assets/js/scripts.js'])
// .pipe(sourcemaps.init())
.pipe(plumber())
// .pipe(babel({
// "plugins": ["@babel/plugin-proposal-class-properties"],
// "presets": ["@babel/preset-env"]
// }))
.pipe(webpackstream(webpackconfig, webpack))
.pipe(concat('all.js'))
// .pipe(sourcemaps.write("./assets/built/"))
.pipe(rename('application.js'))
.pipe(gulp.dest('./assets/built/'))
// .pipe(browsersync.stream())
)
}
// Watch files
function watchFiles() {
gulp.watch("./assets/sass/**/*", css);
gulp.watch("./assets/js/**/*", scripts);
}
const js = gulp.series(scripts);
const build = gulp.series(gulp.parallel(css, js));
// const watch = gulp.parallel(watchFiles, browserSync);
const watch = gulp.parallel(watchFiles);
exports.css = css;
exports.js = js;
exports.build = build;
exports.watch = watch;
exports.default = watch;