Skip to content

Commit

Permalink
Added sitemap and updated gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
nashidahmed committed Nov 10, 2023
1 parent d58e7a3 commit 9619e5d
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 91 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/npm-gulp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ jobs:
name: dist
path: dist

- name: List files
run: ls -R

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
196 changes: 108 additions & 88 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,166 +1,186 @@
// Include the required tools used on tasks
const { watch, src, series, dest, parallel } = require('gulp');
const terser = require('gulp-terser');
const newer = require("gulp-newer");
const babel = require("gulp-babel");
const postcss = require('gulp-postcss');
const cleanCSS = require('gulp-clean-css');
const cssbeautify = require('gulp-cssbeautify');
const concat = require('gulp-concat');
const htmlmin = require('gulp-htmlmin');
const inlinesource = require('gulp-inline-source');
const cachebust = require('gulp-cache-bust');
const eslint = require('gulp-eslint');
const imagemin = require("gulp-imagemin");
const autoprefixer = require('autoprefixer');
const del = require('del');
// Include the required tools used on tasks
const { watch, src, series, dest, parallel } = require("gulp")
const terser = require("gulp-terser")
const newer = require("gulp-newer")
const babel = require("gulp-babel")
const postcss = require("gulp-postcss")
const cleanCSS = require("gulp-clean-css")
const cssbeautify = require("gulp-cssbeautify")
const concat = require("gulp-concat")
const htmlmin = require("gulp-htmlmin")
const inlinesource = require("gulp-inline-source")
const cachebust = require("gulp-cache-bust")
const eslint = require("gulp-eslint")
const imagemin = require("gulp-imagemin")
const autoprefixer = require("autoprefixer")
const del = require("del")

// Initialise plugins
const browsersync = require('browser-sync').create();
const browsersync = require("browser-sync").create()
// const reload = browserSync.reload;

// Specify the Source files
const SRC_HTML = ['index.html'];
const SRC_JS = 'app.js';
const SRC_JS_MODULES = ['assets/js/jquery-3.5.1.min.js', 'assets/js/jquery-ui-1.12.1.min.js', 'assets/js/lazysizes.min.js'];
const SRC_CSS = ['assets/css/*.css', '!assets/css/preloader.css'];
const SRC_IMG = 'assets/img/*';
const SRC_PDF = 'assets/pdf/*';
const SRC_HTML = ["index.html"]
const SRC_JS = "app.js"
const SRC_JS_MODULES = [
"assets/js/jquery-3.5.1.min.js",
"assets/js/jquery-ui-1.12.1.min.js",
"assets/js/lazysizes.min.js",
]
const SRC_CSS = ["assets/css/*.css", "!assets/css/preloader.css"]
const SRC_IMG = "assets/img/*"
const SRC_PDF = "assets/pdf/*"

// Specify the Destination folders
const DEST_HTML = 'dist/';
const DEST_JS = 'dist/js';
const DEST_CSS = 'dist/css';
const DEST_IMG = 'dist/img';
const DEST_PDF = 'dist/pdf';
const DEST_HTML = "dist/"
const DEST_JS = "dist/js"
const DEST_CSS = "dist/css"
const DEST_IMG = "dist/img"
const DEST_PDF = "dist/pdf"

// BrowserSync
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./dist/"
baseDir: "./dist/",
},
port: 3000
});
done();
port: 3000,
})
done()
}

// BrowserSync Reload
function browserSyncReload(done) {
browsersync.reload();
done();
browsersync.reload()
done()
}

// CLEAN files
function htmlClean() {
return del([DEST_HTML]);
return del([DEST_HTML])
}

function jsClean() {
return del([DEST_JS]);
return del([DEST_JS])
}

function cssClean() {
return del([DEST_CSS]);
return del([DEST_CSS])
}

function imgClean() {
return del(['./dist/assets']);
return del(["./dist/assets"])
}

// Lint files
function lint() {
return src(SRC_JS)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
.pipe(eslint.failAfterError())
}

// Build JS
// Build JS
function jsBuild() {
return src(SRC_JS)
.pipe(babel())
.pipe(terser())
.pipe(concat('app.min.js'))
.pipe(dest(DEST_JS));
.pipe(concat("app.min.js"))
.pipe(dest(DEST_JS))
}

// Build CSS
// Build CSS
function cssBuild() {
return src(SRC_CSS)
.pipe(postcss([autoprefixer()]))
.pipe(cssbeautify({ autosemicolon: true }))
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(concat('styles.min.css'))
.pipe(dest(DEST_CSS));
.pipe(cleanCSS({ compatibility: "ie8" }))
.pipe(concat("styles.min.css"))
.pipe(dest(DEST_CSS))
}

function htmlBuild() {
return src(SRC_HTML)
.pipe(htmlmin({ collapseWhitespace: true, removeComments: true }))
.pipe(inlinesource({ compress: true }))
.pipe(cachebust({
type: 'timestamp'
}))
.pipe(dest(DEST_HTML));
.pipe(
cachebust({
type: "timestamp",
})
)
.pipe(dest(DEST_HTML))
}

function images() {
return src(SRC_IMG)
.pipe(newer(DEST_IMG))
.pipe(imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [{
removeViewBox: false,
collapseGroups: true
}]
})
]))
.pipe(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [
{
removeViewBox: false,
collapseGroups: true,
},
],
}),
])
)
.pipe(dest(DEST_IMG))
.pipe(dest('dist/img'));
.pipe(dest("dist/img"))
}

function jsModulesCopy() {
return src(SRC_JS_MODULES)
.pipe(dest(DEST_JS));
return src(SRC_JS_MODULES).pipe(dest(DEST_JS))
}

function copyFiles() {
return src('googlec6cb74579ce2fc25.html')
.pipe(dest(DEST_HTML))
return src([
"googlec6cb74579ce2fc25.html",
"sitemap.xml",
"robots.txt",
"README.md",
]).pipe(dest(DEST_HTML))
}

function pdfCopy() {
return src(SRC_PDF)
.pipe(dest(DEST_PDF));
return src(SRC_PDF).pipe(dest(DEST_PDF))
}

// WATCH for file changes and run the tasks
function watchFiles() {
watch(SRC_JS, jsBuild);
watch(SRC_JS_MODULES, jsModulesCopy);
watch(SRC_CSS, cssBuild);
watch(SRC_PDF, pdfCopy);
watch(['assets/css/preloader.css', 'index.html'], htmlBuild);
watch(SRC_IMG, images);
watch([...SRC_JS, ...SRC_CSS, 'index.html'], browserSyncReload);
watch(SRC_JS, jsBuild)
watch(SRC_JS_MODULES, jsModulesCopy)
watch(SRC_CSS, cssBuild)
watch(SRC_PDF, pdfCopy)
watch(["assets/css/preloader.css", "index.html"], htmlBuild)
watch(SRC_IMG, images)
watch([...SRC_JS, ...SRC_CSS, "index.html"], browserSyncReload)
}

const clean = parallel(jsClean, cssClean, imgClean);
const build = parallel(htmlBuild, jsBuild, cssBuild, images, jsModulesCopy, pdfCopy, copyFiles);
const watcher = parallel(watchFiles, browserSync);
const clean = parallel(jsClean, cssClean, imgClean)
const build = parallel(
htmlBuild,
jsBuild,
cssBuild,
images,
jsModulesCopy,
pdfCopy,
copyFiles
)
const watcher = parallel(watchFiles, browserSync)

// Export tasks
exports.lint = lint;
exports.htmlBuild = series(htmlClean, htmlBuild);
exports.jsBuild = series(jsClean, lint, parallel(jsBuild, jsModulesCopy));
exports.cssBuild = series(cssClean, cssBuild);
exports.pdfCopy = pdfCopy;
exports.jsModulesCopy = jsModulesCopy;
exports.images = images;
exports.watch = watcher;
exports.build = build;
exports.default = series(clean, build);
exports.lint = lint
exports.htmlBuild = series(htmlClean, htmlBuild)
exports.jsBuild = series(jsClean, lint, parallel(jsBuild, jsModulesCopy))
exports.cssBuild = series(cssClean, cssBuild)
exports.pdfCopy = pdfCopy
exports.jsModulesCopy = jsModulesCopy
exports.images = images
exports.watch = watcher
exports.build = build
exports.default = series(clean, build)
19 changes: 19 additions & 0 deletions sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

<url>
<loc>https://nashidahmed.github.io/</loc>
<lastmod>2020-11-22</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>

<url>
<loc>https://nashidahmed.github.io/pdf/RFID_vending_machine_thesis.pdf</loc>
<lastmod>2020-11-22</lastmod>
<changefreq>never</changefreq>
</url>

</urlset>

0 comments on commit 9619e5d

Please sign in to comment.