-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (80 loc) · 2.66 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var browserSync = require('browser-sync').create();
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssvariables = require('postcss-css-variables');
var calc = require('postcss-calc');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var version = require('gulp-version-number');
// js file paths
var utilJsPath = 'craft/web/assets/js'; // util.js path - you may need to update this if including the framework as external node module
var componentsJsPath = 'craft/web/assets/js/components/*.js'; // component js files
var scriptsJsPath = 'craft/web/assets/js'; //folder for final scripts.js/scripts.min.js files
// css file paths
var cssFolder = 'craft/web/assets/css'; // folder for final style.css/style-custom-prop-fallbac.css files
var scssFilesPath = 'craft/web/assets/css/**/*.scss'; // scss files to watch
function reload(done) {
browserSync.reload();
done();
}
// const versionConfig = {
// 'value': '%MDS%',
// 'append': {
// 'key': 'v',
// 'to': ['css', 'js'],
// },
// };
// gulp.task('twig', function() {
// return gulp.src('craft/templates/**/*.twig')
// .pipe($.htmlmin({collapseWhitespace: true}))
// .pipe($.versionNumber(versionConfig))
// .pipe(gulp.dest('docroot'));
// });
gulp.task('sass', function() {
return gulp.src(scssFilesPath)
.pipe(sassGlob())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(postcss([autoprefixer()]))
.pipe(gulp.dest(cssFolder))
.pipe(browserSync.reload({
stream: true
}))
.pipe(rename('style-fallback.css'))
.pipe(postcss([cssvariables(), calc()]))
.pipe(gulp.dest(cssFolder));
});
gulp.task('scripts', function() {
return gulp.src([utilJsPath+'/util.js', componentsJsPath])
.pipe(concat('scripts.js'))
.pipe(gulp.dest(scriptsJsPath))
.pipe(browserSync.reload({
stream: true
}))
.pipe(rename('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest(scriptsJsPath))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('browserSync', gulp.series(function (done) {
browserSync.init({
port: 8080,
proxy: 'mkgn4.local',
// server: {
// baseDir: 'main'
// },
notify: false
})
done();
}));
gulp.task('watch', gulp.series(['browserSync', 'sass', 'scripts'], function () {
gulp.watch('craft/templates/**/*.twig', gulp.series(reload));
//gulp.watch('main/*.twig', gulp.series(reload));
gulp.watch('craft/web/assets/css/**/*.scss', gulp.series(['sass']));
gulp.watch(componentsJsPath, gulp.series(['scripts']));
}));