Skip to content

Commit

Permalink
Merge pull request #1 from jerboa88/rewrite-in-typescript
Browse files Browse the repository at this point in the history
Rewrite in typescript
  • Loading branch information
jerboa88 authored Mar 9, 2024
2 parents 4183046 + 03836be commit a341b5e
Show file tree
Hide file tree
Showing 15 changed files with 12,266 additions and 1,486 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/static.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
name: Deploy to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
# Enable running this workflow manually from the Actions tab
workflow_dispatch:
push:
branches:
- main

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
Expand All @@ -22,22 +20,33 @@ concurrency:
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Run build command
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
path: ./dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
83 changes: 83 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import gulp from 'gulp';
import typescript from 'gulp-typescript';
import htmlmin from 'gulp-htmlmin';
import imagemin from 'gulp-imagemin';
import copy from 'gulp-copy';
import connect from 'gulp-connect';
import gulpSass from 'gulp-sass';
import nodeSass from "node-sass";


const sass = gulpSass(nodeSass);
const globs = {
ts: 'src/**/*.ts',
scss: 'src/**/*.scss',
html: 'src/**/*.html',
images: 'src/**/*.+(png|jpg|jpeg|gif|svg)',
other: ['src/site.webmanifest'],
};

// Task to compile TypeScript files to JavaScript
gulp.task('typescript', () => {
return gulp.src(globs.ts)
.pipe(typescript())
.pipe(gulp.dest('dist'));
});

// Task to compile SCSS files to CSS
gulp.task('sass', () => {
return gulp.src(globs.scss)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist'));
});

// Task to minify HTML files
gulp.task('htmlmin', () => {
return gulp.src(globs.html)
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('dist'));
});

// Task to minify images
gulp.task('imagemin', () => {
return gulp.src(globs.images)
.pipe(imagemin())
.pipe(gulp.dest('dist'));
});

// Task to copy other files from src to dist
gulp.task('copy', () => {
return gulp.src(globs.other)
.pipe(copy('dist', { prefix: 1 }));
});

// Task to start HTTP server
gulp.task('serve', () => {
connect.server({
root: 'dist',
port: 8000,
livereload: true,
});
});

// Task to reload the server
gulp.task('reload', (done) => {
gulp.src('dist')
.pipe(connect.reload());
done();
});

// Task to watch changes in files
gulp.task('watch', () => {
gulp.watch(globs.ts, gulp.series('typescript', 'reload'));
gulp.watch(globs.scss, gulp.series('sass', 'reload'));
gulp.watch(globs.html, gulp.series('htmlmin', 'reload'));
gulp.watch(globs.images, gulp.series('imagemin', 'reload'));
gulp.watch(globs.other, gulp.series('copy', 'reload'));
});

// Build task
gulp.task('build', gulp.parallel('typescript', 'sass', 'htmlmin', 'imagemin', 'copy'));

// Default task
gulp.task('default', gulp.series('build', gulp.parallel('serve', 'watch')));
Loading

0 comments on commit a341b5e

Please sign in to comment.