{"id":17274224,"url":"https://github.com/davidthorn/blackjack-api","last_synced_at":"2025-03-26T13:26:47.078Z","repository":{"id":122657033,"uuid":"159187665","full_name":"davidthorn/blackjack-api","owner":"davidthorn","description":"A project which I am doing in my spare time to create a BlackJack game. This will be used for the brain of the game and the actual game logic will be create else where.","archived":false,"fork":false,"pushed_at":"2018-11-27T23:44:10.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T14:47:58.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidthorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-26T15:05:56.000Z","updated_at":"2018-11-27T23:44:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5ddb494-daf8-459d-b2b0-e1d64af1dd7a","html_url":"https://github.com/davidthorn/blackjack-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidthorn%2Fblackjack-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidthorn%2Fblackjack-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidthorn%2Fblackjack-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidthorn%2Fblackjack-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidthorn","download_url":"https://codeload.github.com/davidthorn/blackjack-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245661523,"owners_count":20651879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T08:53:23.673Z","updated_at":"2025-03-26T13:26:47.057Z","avatar_url":"https://github.com/davidthorn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webpack and Typescript\n\nThis project provides a basic skeleton project which can be used to initialise typescript / webpack projects.\n\nIt is not the most difficult task but it is very annoying having to configure it every time you start a new project.\n\n# Clone project\n\nStart off by cloning this project and then change into that directory\n\n```bash\n\ngit clone https://github.com/davidthorn/webpack-typescript.git \u003cproject_name\u003e\ncd \u003cproject_name\u003e\n\n```\n\n# Creating this project\n\n### Initialise the npm project\n\nIn order to use ```npm``` we require to have a ```package.json``` within the project, to do this we can run the ```npm init``` command:\n\n```\nnpm init\n```\n\nYou should changed the ```\"name\", \"description\", \"repository\"``` properties etc to suite your own project.\n\n# Install dependencies\n\nWe only need webpack for development mode so we can supply ```--save-dev```instead of just ``--save``.\n\nRun the following command to install webpack and its cli\n\n```\nnpm install --save-dev webpack webpack-cli\n```\n\n# Install Typescript\n\nNow in order to use Typescript you are going to have to install the language and its transpiler. So install the following package using the -g global command.\n\n```\nnpm install -g --save-dev typescript\n```\n\nWebpack recommends using the ```ts-loader```. To be honest I am not sure what it does and have not researched it either, I just installed it.\n\n```\nnpm install --save-dev ts-loader\n```\n\n# Quick Start\n\nYou can run all these commands in one go, \n\n```\nnpm install --save-dev typescript ts-loader webpack webpack-cli\n```\n\n# Create Webpack config file\n\nWebpack requires a configuration file: `webpack.config.js` to be located within your project so as to know where to output the vanilla javascript code etc.\n\nThe installation guide can be found using this link:\n[Webpack \u0026 Typscript Configuration guide](https://webpack.js.org/guides/typescript/)\n\nWebpack requires initially that it has a typescript configuration file (`tsconfig.json`) too, therefore we need to create one.\n\nThis can be done using the typescripts compiler command line interface.\n\n```\ntsc --init  \n```\n\nThis command should have created a `tsconfig.json` in the root directory of your project.\n\nFrom what I understand we can leave it exactly as it is.\n\nNext create the `webpack.config.js` file in the root directory of your project:\n\n```\ntouch webpack.config.js\n```\n\nThen paste the following code in to that file:\n\n```javascript\nconst path = require('path');\n\nmodule.exports = {\n  mode: \"development\",\n  watch: false,\n  entry: './src/main.ts',\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        use: 'ts-loader',\n        exclude: /node_modules/\n      }\n    ]\n  },\n  resolve: {\n    extensions: [ '.tsx', '.ts', '.js' ]\n  },\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist')\n  }\n};\n```\n\nNearly there.\n\n# NPM build command\n\nWe now need to create a npm command within the `package.json` file in order for this project to be built.\n\nAdd the following line to `\"scripts\"` block in the `package.json` file:\n\n``` \n...,\n\"scripts\": {\n  ...\n  \"build\" : \"webpack\"\n},\n...\n```\n\nYou will notice within the `package.json` within this project that it also calls the `tsc` at the end of the build command. This is so that I can review the vanilla code if required.\n\nTo build you project you can now run the following command in your terminal:\n\n```\nnpm run build\n```\nYou should notice that a `bundle.js` file has been created within your `dist` folder.\n\nIf you want to change the outputted filename of `bundle.js` to a custom file name the you need to up the `webpack.config.js` file. Change `bundle.js` to whatever you want the file to be called\n\n```\noutput: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist')\n}\n```\n\n# Optional content\n\nDue to webpack creating a `dist` directory for your `bundle.js` I decided that it is easy to place all non javascript / typescript files in an `assets` folders within the root folder. Prior to the build command being run, we copy the contents of the `assets` directory to the `dist` directory.\n\n```\nmkdir assets\ntouch assets/layout.css\ntouch assets/index.html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidthorn%2Fblackjack-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidthorn%2Fblackjack-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidthorn%2Fblackjack-api/lists"}