From 5ae57c1910758940a2cc44e29da02006cd121adc Mon Sep 17 00:00:00 2001 From: neverix Date: Wed, 6 Mar 2019 15:25:58 +0700 Subject: [PATCH] basic typescript+webpack setup --- .gitignore | 2 ++ package.json | 36 +++++++++++++++++++++++++ src/index.html | 13 ++++++++++ src/index.ts | 2 ++ src/scss/base.scss | 3 +++ src/ts/main.ts | 1 + tsconfig.json | 28 ++++++++++++++++++++ webpack.config.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 150 insertions(+) create mode 100644 .gitignore create mode 100644 package.json create mode 100644 src/index.html create mode 100644 src/index.ts create mode 100644 src/scss/base.scss create mode 100644 src/ts/main.ts create mode 100644 tsconfig.json create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..504afef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..748c9fc --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "html5-game-template", + "version": "1.0.0", + "description": "A template for writing jam games in HTML5 + TypeScript", + "main": "./src/index.ts", + "scripts": { + "start": "webpack-dev-server --open --mode development", + "build": "webpack --mode production" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/neverix/html5-game-template.git" + }, + "author": "neverix", + "license": "MIT", + "bugs": { + "url": "https://github.com/neverix/html5-game-template/issues" + }, + "homepage": "https://github.com/neverix/html5-game-template#readme", + "devDependencies": { + "css-loader": "^2.1.0", + "extract-text-webpack-plugin": "^4.0.0-beta.0", + "file-loader": "^3.0.1", + "html-loader": "^0.5.5", + "html-webpack-plugin": "^3.2.0", + "node-sass": "^4.11.0", + "sass-loader": "^7.1.0", + "source-map-loader": "^0.2.4", + "style-loader": "^0.23.1", + "ts-loader": "^5.3.3", + "typescript": "^3.3.3333", + "webpack": "^4.29.5", + "webpack-cli": "^3.2.3", + "webpack-dev-server": "^3.2.0" + } +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..83ae23d --- /dev/null +++ b/src/index.html @@ -0,0 +1,13 @@ + + + + + Game + + + + + + + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..50cb788 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +import "./ts/main" +import "./scss/base.scss" \ No newline at end of file diff --git a/src/scss/base.scss b/src/scss/base.scss new file mode 100644 index 0000000..375a34a --- /dev/null +++ b/src/scss/base.scss @@ -0,0 +1,3 @@ +body { + padding: 0 +} \ No newline at end of file diff --git a/src/ts/main.ts b/src/ts/main.ts new file mode 100644 index 0000000..8c1ba46 --- /dev/null +++ b/src/ts/main.ts @@ -0,0 +1 @@ +console.log("hello world!") \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2730819 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "*": [ + "types/*" + ] + }, + "module": "es6", + "target": "es5", + "removeComments": true, + "sourceMap": true, + "lib": [ + "es2015", + "es2017", + "dom" + ], + "noImplicitAny": true, + "alwaysStrict": true, + "moduleResolution": "Node" + }, + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..856d7dc --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,65 @@ +const HtmlWebPackPlugin = require("html-webpack-plugin"); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +module.exports = { + devtool: 'inline-source-map', + module: { + rules: [ + { + test: /\.ts$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /\.html$/, + use: [ + { + loader: "html-loader" + } + ] + }, + { + test: /\.(png|mp3|wav)$/, + use: [ + { + loader: 'file-loader', + options: {} + } + ] + }, + { + test: /\.(scss|sass)$/, + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: ['css-loader', 'sass-loader'] + }) + }, + { + test: /\.(eot|svg|ttf|woff|woff2)$/, + use: { + loader: 'file-loader?name=./res/fonts/[name].[ext]' + } + } + ] + }, + plugins: [ + new HtmlWebPackPlugin({ + template: "./src/index.html", + filename: "./index.html" + }), + new ExtractTextPlugin( + { + filename: 'style.css', + allChunks: true + } + ) + ], + resolve: { + extensions: [ + ".js", + ".ts" + ] + }, + entry: [ + "./src/index.ts" + ] +};