Compare commits

...

2 commits

5 changed files with 1580 additions and 5 deletions

View file

@ -1,7 +1,11 @@
import GulpClient from "gulp";
import browserSync, { BrowserSyncInstance } from "browser-sync";
import GulpClient, { TaskFunction } from "gulp";
import path from "upath";
import { Context } from "./gulp/Context.js";
const { dest, parallel, src } = GulpClient;
const { dest, parallel, series, src, watch } = GulpClient;
const { join } = path;
const context = new Context();
/**
@ -80,3 +84,73 @@ export function Build(): Promise<void>
});
});
}
/**
* Reloads all browsers using `browser-sync`.
*
* @param syncer
* The browser-sync instance to work on.
*
* @param filePath
* A glob-path which points to the files which must be reloaded.
*
* @returns
* The actual task.
*/
function BrowserSync(syncer: BrowserSyncInstance, filePath?: string): TaskFunction
{
let BrowserSync: TaskFunction = (done) =>
{
if (filePath)
{
syncer.reload(filePath);
}
else
{
syncer.reload();
}
done();
};
return BrowserSync;
}
/**
* Builds and watches the files for changes.
*/
export function Watch(): void
{
let syncer = browserSync.create();
Build();
syncer.init({
open: false,
server: context.StaticPath(),
online: false
});
watch(
context.SourcePath(context.JSDirName),
series(
JavaScript,
BrowserSync(syncer, "*.js")));
watch(
context.SourcePath(context.StyleDirName, "**", "*.css"),
series(
Styles,
BrowserSync(syncer, "*.css")));
watch(
context.SourcePath(context.AssetDirName),
series(
Assets,
BrowserSync(syncer, join(context.AssetDirName, "**", "*"))));
watch(
context.SourcePath("**", "*.html"),
series(
WebPages,
BrowserSync(syncer, "*.html")));
}

1492
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,8 +12,10 @@
"devDependencies": {
"@manuth/eslint-plugin-typescript": "^4.0.0",
"@manuth/tsconfig": "^3.0.2",
"@types/browser-sync": "^2.26.3",
"@types/gulp": "^4.0.10",
"@types/node": "^18.11.10",
"browser-sync": "^2.27.10",
"cross-env": "^7.0.3",
"eslint": "^8.23.1",
"gulp": "^4.0.2",

13
src/index.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Connect Four</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./styles/style.css">
<script src="./js/main.js"></script>
</head>
<body>
<h1>Welcome to ConnectForce</h1>
</body>
</html>

0
src/styles/style.css Normal file
View file