basic typescript+webpack setup

This commit is contained in:
neverix 2019-03-06 15:25:58 +07:00
parent 386d92ca1a
commit 5ae57c1910
8 changed files with 150 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules/
package-lock.json

36
package.json Normal file
View file

@ -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"
}
}

13
src/index.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Game</title>
<link rel='stylesheet' href='style.css'>
</head>
<body>
</body>
</html>

2
src/index.ts Normal file
View file

@ -0,0 +1,2 @@
import "./ts/main"
import "./scss/base.scss"

3
src/scss/base.scss Normal file
View file

@ -0,0 +1,3 @@
body {
padding: 0
}

1
src/ts/main.ts Normal file
View file

@ -0,0 +1 @@
console.log("hello world!")

28
tsconfig.json Normal file
View file

@ -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"
]
}

65
webpack.config.js Normal file
View file

@ -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"
]
};