diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1a6bd45 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +package-lock.json binary diff --git a/.gitignore b/.gitignore index 56158b3..9ed75c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,104 @@ -# Output -build/* +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/ + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..9ab4584 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,91 @@ +module.exports = grunt => { + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + clean: { + before: ["build/"], + after: [".tscache/"] + }, + copy: { + images: { + files: [{expand: true, cwd: "src/", src: ["**/*.png", "**/*.ico"], dest: "build/"}] + }, + html: { + files: [{expand: true, cwd: "src/", src: "**/*.html", dest: "build/"}] + }, + css: { + files: [{expand: true, cwd: "src/", src: "**/*.css", dest: "build/"}] + } + }, + cssmin: { + default: { + files: [{expand: true, cwd: "build/", src: "**/*.css", dest: "build/"}] + } + }, + htmlmin: { + default: { + files: [{expand: true, cwd: "build/", src: "**/*.html", dest: "build/"}], + options: { + removeComments: true, + collapseWhitespace: true + } + } + }, + terser: { + default: { + files: [{expand: true, cwd: "build/js/", src: "*.js", dest: "build/js/"}], + options: { + compress: true, + mangle: false, + module: true + } + } + }, + ts: { + dev: { + tsconfig: "./tsconfig.json" + }, + deploy: { + tsconfig: "./tsconfig.json", + options: { + sourceMap: false + } + } + } + }); + + grunt.loadNpmTasks("grunt-contrib-clean"); + grunt.loadNpmTasks("grunt-contrib-copy"); + grunt.loadNpmTasks("grunt-contrib-cssmin"); + grunt.loadNpmTasks("grunt-contrib-htmlmin"); + grunt.loadNpmTasks("grunt-terser"); + grunt.loadNpmTasks("grunt-ts"); + + grunt.registerTask("default", [ + // Pre + "clean:before", + // Copy files + "copy:images", + "copy:html", + "copy:css", + // Compile + "ts:dev", + // Post + "clean:after" + ]); + grunt.registerTask("deploy", [ + // Pre + "clean:before", + // Copy files + "copy:images", + "copy:html", + "copy:css", + // Compile JS + "ts:deploy", + // Minify + "terser", + "cssmin", + "htmlmin", + // Post + "clean:after" + ]); +}; diff --git a/README.md b/README.md index 1230a6e..acb13c3 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,22 @@ The source code of [my personal website](https://fwdekker.com/). ## Development +### Prerequisites +* [npm](https://www.npmjs.com/) +* [grunt-cli](https://www.npmjs.com/package/grunt-cli) + +### CLI ```shell script -# Build the website in `build/` -$> ./build.sh +# Install dependencies (only needed once) +$> npm install ``` + ```shell script -# Build the website in `build/` then copy it to `example/` -$> ./build.sh "example/" +# Build the application in `build/` for development +$> grunt +``` + +```shell script +# Build the application in `build/` for deployment +$> grunt deploy ``` diff --git a/build.sh b/build.sh deleted file mode 100755 index fb60af8..0000000 --- a/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -mkdir -p build build/js build/css - -tsc -p ./tsconfig.json - -cp ./*.html ./build/ -cp ./css/*.css ./build/css -cp ./favicon.ico ./build/favicon.ico -cp ./favicon.png ./build/favicon.png - -if [ "$1" ]; then - cp -r ./build/ "$1" -fi diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..69ba2a6 Binary files /dev/null and b/package-lock.json differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..517dfcf --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "fwdekker.com", + "version": "1.0.0", + "description": "The source code of [my personal website](https://fwdekker.com/).", + "dependencies": {}, + "devDependencies": { + "grunt": "1.0.4", + "grunt-contrib-clean": "2.0.0", + "grunt-contrib-copy": "1.0.0", + "grunt-contrib-cssmin": "3.0.0", + "grunt-contrib-htmlmin": "3.1.0", + "grunt-terser": "1.0.0", + "grunt-ts": "6.0.0-beta.22", + "typescript": "3.6.4" + }, + "repository": { + "type": "git", + "url": "git@git.fwdekker.com:FWDekker/fwdekker.com.git" + }, + "author": "Felix W. Dekker" +} diff --git a/css/main.css b/src/css/main.css similarity index 100% rename from css/main.css rename to src/css/main.css diff --git a/favicon.ico b/src/favicon.ico similarity index 100% rename from favicon.ico rename to src/favicon.ico diff --git a/favicon.png b/src/favicon.png similarity index 100% rename from favicon.png rename to src/favicon.png diff --git a/index.html b/src/index.html similarity index 100% rename from index.html rename to src/index.html diff --git a/js/commands.ts b/src/js/commands.ts similarity index 100% rename from js/commands.ts rename to src/js/commands.ts diff --git a/js/extensions.d.ts b/src/js/extensions.d.ts similarity index 100% rename from js/extensions.d.ts rename to src/js/extensions.d.ts diff --git a/js/extensions.ts b/src/js/extensions.ts similarity index 100% rename from js/extensions.ts rename to src/js/extensions.ts diff --git a/js/fs.ts b/src/js/fs.ts similarity index 100% rename from js/fs.ts rename to src/js/fs.ts diff --git a/js/shared.ts b/src/js/shared.ts similarity index 100% rename from js/shared.ts rename to src/js/shared.ts diff --git a/js/terminal.ts b/src/js/terminal.ts similarity index 100% rename from js/terminal.ts rename to src/js/terminal.ts diff --git a/tsconfig.json b/tsconfig.json index 340b6ff..587f2a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,17 +2,16 @@ "compilerOptions": { "module": "esnext", "target": "es2019", - "sourceMap": true, "strict": true, - "removeComments": true, - "outDir": "./build/js" + "rootDir": "./src/js/", + "outDir": "./build/js/" }, "files": [ - "js/commands.ts", - "js/extensions.d.ts", - "js/extensions.ts", - "js/fs.ts", - "js/shared.ts", - "js/terminal.ts" + "src/js/commands.ts", + "src/js/extensions.d.ts", + "src/js/extensions.ts", + "src/js/fs.ts", + "src/js/shared.ts", + "src/js/terminal.ts" ] }