initial commit
This commit is contained in:
commit
e5d0678b5d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
dist/
|
34
gulpfile.js
Normal file
34
gulpfile.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
var gulp = require('gulp');
|
||||||
|
var browserify = require('browserify');
|
||||||
|
var source = require('vinyl-source-stream');
|
||||||
|
var watchify = require('watchify');
|
||||||
|
var tsify = require('tsify');
|
||||||
|
var fancy_log = require('fancy-log');
|
||||||
|
var paths = {
|
||||||
|
pages: ['src/*.html']
|
||||||
|
};
|
||||||
|
|
||||||
|
var watchedBrowserify = watchify(browserify({
|
||||||
|
basedir: '.',
|
||||||
|
debug: true,
|
||||||
|
entries: ['src/main.ts'],
|
||||||
|
cache: {},
|
||||||
|
packageCache: {}
|
||||||
|
}).plugin(tsify));
|
||||||
|
|
||||||
|
gulp.task('copy-html', function () {
|
||||||
|
return gulp.src(paths.pages)
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
});
|
||||||
|
|
||||||
|
function bundle() {
|
||||||
|
return watchedBrowserify
|
||||||
|
.bundle()
|
||||||
|
.on('error', fancy_log)
|
||||||
|
.pipe(source('bundle.js'))
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('default', gulp.series(gulp.parallel('copy-html'), bundle));
|
||||||
|
watchedBrowserify.on('update', bundle);
|
||||||
|
watchedBrowserify.on('log', fancy_log);
|
4204
package-lock.json
generated
Normal file
4204
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
package.json
Normal file
21
package.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "gameengine",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A game engine written in TypeScript",
|
||||||
|
"main": "./dist/main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Joe Weaver",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"browserify": "^16.5.1",
|
||||||
|
"fancy-log": "^1.3.3",
|
||||||
|
"gulp": "^4.0.0",
|
||||||
|
"gulp-typescript": "^6.0.0-alpha.1",
|
||||||
|
"tsify": "^5.0.0",
|
||||||
|
"typescript": "^3.9.7",
|
||||||
|
"vinyl-source-stream": "^2.0.0",
|
||||||
|
"watchify": "^3.11.1"
|
||||||
|
}
|
||||||
|
}
|
6
readme.md
Normal file
6
readme.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Game Engine
|
||||||
|
## How to transpile and run
|
||||||
|
|
||||||
|
Start gulp by just running `gulp` in the console. Start the code by running `dist/main.js` with Web Server for Chrome or a similar product. Anytime you save, gulp should recompile the code automatically.
|
||||||
|
|
||||||
|
Setup follows [this helpful guide from TypeScript] (https://www.typescriptlang.org/docs/handbook/gulp.html) (Up through Watchify).
|
3
src/greet.ts
Normal file
3
src/greet.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function sayHello(name: string){
|
||||||
|
return `Hello from ${name}`;
|
||||||
|
}
|
11
src/index.html
Normal file
11
src/index.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Hello World!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p id="greeting">Loading ...</p>
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
8
src/main.ts
Normal file
8
src/main.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { sayHello } from './greet';
|
||||||
|
|
||||||
|
function showHello(divName: string, name: string) {
|
||||||
|
const elt = document.getElementById(divName);
|
||||||
|
elt.innerText = sayHello(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
showHello('greeting', 'TypeScript');
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"src/main.ts",
|
||||||
|
"src/greet.ts"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"target": "es5"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user