theme for RDM site
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.1 KiB

3 years ago
//@format
const yaml = require('js-yaml');
const fs = require('fs');
const { SITE, PORT, BSREWRITE, PATHS } = loadConfig();
//var server = require('browser-sync').create();
//global.server = server;
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const autoprefixer = require('gulp-autoprefixer');
const sass = require('gulp-sass')(require('sass'));
const browsersync = require('browser-sync').create();
const sourcemaps = require('gulp-sourcemaps');
3 years ago
3 years ago
function loadConfig() {
var ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
}
3 years ago
3 years ago
// BrowserSync
function bsInit(done) {
browsersync.init({
logLevel: 'debug',
proxy: 'https://roblib_2022.lndo.site'
});
done();
}
3 years ago
3 years ago
function bsInit__remote(done) {
browsersync.init({
proxy: SITE.Remote.Url,
serveStatic: ['.'],
files: PATHS.Watch,
plugins: ['bs-rewrite-rules'],
rewriteRules: [
{
match: BSREWRITE.Css.Match,
replace: BSREWRITE.Css.Replace
},
{
match: BSREWRITE.Js.Match,
replace: BSREWRITE.Js.Replace
}
]
});
done();
}
3 years ago
3 years ago
// BrowserSync Reload
function bsReload(done) {
browsersync.reload();
done();
}
3 years ago
3 years ago
var cp = require('child_process');
function drush() {
return cp.exec('lando drush cr');
}
3 years ago
3 years ago
// Compile CSS
function styles() {
'use strict';
return gulp
.src(PATHS.Scss.Dir + '/**/*.scss')
.pipe(plumber())
3 years ago
.pipe(sourcemaps.init())
3 years ago
.pipe(
sass
.sync({
includePaths: PATHS.Scss.Libraries
})
.on('error', sass.logError)
)
3 years ago
.pipe(sourcemaps.write('.'))
3 years ago
.pipe(gulp.dest(PATHS.Css.Dir))
.pipe(browsersync.stream());
}
3 years ago
3 years ago
// Watch Files
function watchFiles() {
'use strict';
gulp.watch(PATHS.Scss.Dir + '/**/*.scss', styles);
gulp.watch('./templates/**/*.twig', drush);
}
3 years ago
3 years ago
// Group complex tasks
const build = gulp.parallel(styles);
const watch = gulp.series(styles, gulp.parallel(watchFiles, bsInit));
3 years ago
3 years ago
// Export tasks
exports.build = build;
exports.styles = styles;
exports.drush = drush;
exports.watch = watch;
exports.default = watch;