2022-11-21 16:49:04 +00:00
|
|
|
const { src, dest, watch, parallel } = require('gulp');
|
2022-11-18 20:45:13 +00:00
|
|
|
const sass = require('gulp-sass')(require('sass'));
|
2022-11-18 22:35:12 +00:00
|
|
|
const browserify = require('browserify');
|
|
|
|
const Babelify = require('babelify');
|
|
|
|
const source = require('vinyl-source-stream');
|
|
|
|
const buffer = require('vinyl-buffer');
|
|
|
|
const uglify = require('gulp-uglify');
|
2022-11-21 16:49:04 +00:00
|
|
|
const connect = require('gulp-connect');
|
2022-11-18 22:35:12 +00:00
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
const paths = {
|
|
|
|
html: {
|
|
|
|
all: 'src/templates/**/*.html'
|
|
|
|
},
|
|
|
|
|
2022-11-21 21:55:57 +00:00
|
|
|
img: {
|
2022-11-25 07:26:40 +00:00
|
|
|
all: 'src/assets/images/**',
|
2022-11-21 21:55:57 +00:00
|
|
|
},
|
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
styles: {
|
|
|
|
all: 'src/styles/**/*.scss',
|
|
|
|
main: 'src/styles/main.scss',
|
|
|
|
},
|
|
|
|
|
|
|
|
scripts: {
|
|
|
|
all: 'src/scripts/**/*.js',
|
|
|
|
main: 'src/scripts/app.js',
|
|
|
|
},
|
|
|
|
|
2022-11-23 16:00:43 +00:00
|
|
|
utilities: {
|
|
|
|
all: 'src/scripts/utilities/*.js'
|
|
|
|
},
|
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
output: 'dist',
|
|
|
|
};
|
|
|
|
|
|
|
|
function html () {
|
2022-11-23 16:00:43 +00:00
|
|
|
return src(paths.html.all).pipe(dest(paths.output)).pipe(connect.reload());
|
2022-11-21 16:49:04 +00:00
|
|
|
}
|
2022-11-18 22:35:12 +00:00
|
|
|
|
2022-11-18 20:45:13 +00:00
|
|
|
function styles() {
|
2022-11-23 16:00:43 +00:00
|
|
|
return src(paths.styles.main).pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)).pipe(dest(paths.output)).pipe(connect.reload());
|
2022-11-18 20:45:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
function server () {
|
|
|
|
connect.server({
|
2022-11-21 21:55:57 +00:00
|
|
|
root: 'dist',
|
2022-11-21 16:49:04 +00:00
|
|
|
livereload: true,
|
|
|
|
port: 3000,
|
|
|
|
})
|
|
|
|
}
|
2022-11-18 22:35:12 +00:00
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
function sentinel () {
|
|
|
|
watch(paths.html.all, {ignoreInitial: false}, html);
|
|
|
|
watch(paths.styles.all, {ignoreInitial: false}, styles);
|
|
|
|
watch(paths.scripts.all, {ignoreInitial: false}, scripts);
|
2022-11-21 21:55:57 +00:00
|
|
|
watch(paths.img.all, {ignoreInitial: false}, img);
|
2022-11-23 16:00:43 +00:00
|
|
|
watch(paths.utilities.all, {ignoreInitial: false}, utilities);
|
2022-11-21 16:49:04 +00:00
|
|
|
}
|
2022-11-18 20:45:13 +00:00
|
|
|
|
2022-11-23 16:00:43 +00:00
|
|
|
function utilities () {
|
|
|
|
return src(paths.utilities.all).pipe(dest(paths.output));
|
2022-11-21 16:49:04 +00:00
|
|
|
}
|
2022-11-18 20:45:13 +00:00
|
|
|
|
2022-11-23 16:00:43 +00:00
|
|
|
function scripts () {
|
|
|
|
return browserify(paths.scripts.main).transform(Babelify.configure({presets: ['@babel/preset-env'],})).bundle().pipe(source('bundle.js')).pipe(buffer()).pipe(uglify()).pipe(dest(paths.output)).pipe(connect.reload());
|
|
|
|
}
|
2022-11-21 21:55:57 +00:00
|
|
|
|
|
|
|
function img () {
|
|
|
|
return src(paths.img.all).pipe(dest(paths.output));
|
|
|
|
}
|
|
|
|
|
2022-11-21 16:49:04 +00:00
|
|
|
exports.default = parallel (server, sentinel);
|