Skip to content

Commit ab73fcf

Browse files
committed
init commit
0 parents  commit ab73fcf

13 files changed

+2958
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.idea
3+
dist

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021 Project Error
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<div align="center">
2+
<img href="https://projecterror.dev" width="150" src="https://i.tasoagc.dev/c1pD" alt="Material-UI logo" />
3+
</div>
4+
<h1 align="center">FiveM TypeScript Resource Boilerplate</h1>
5+
6+
<div align="center">
7+
This is a simple boilerplate for getting started with TypeScript game-scripts, in FiveM.
8+
</div>
9+
10+
<div align="center">
11+
12+
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/project-error/pe-utils/master/LICENSE)
13+
![Discord](https://img.shields.io/discord/791854454760013827?label=Our%20Discord)
14+
</div>
15+
16+
This repository is a basic boilerplate for getting started
17+
with TypeScript resources in FiveM. This boilerplate only comes with
18+
development dependencies needed for TypeScript transpilation, the rest
19+
is up to you.
20+
21+
*Note: This boilerplate is targeting TypeScript in context of game-scripts,
22+
if you wish to use TypeScript in NUI, take a look at our other [boilerplate](https://github.com/project-error/fivem-react-boilerplate-lua)*
23+
24+
## Foreword
25+
26+
Although there already is a well established TypeScript boilerplate,
27+
made by [d0p3t](https://github.com/d0p3t/fivem-ts-boilerplate) for the FiveM ecosystem,
28+
he has unfortunately passed away, leaving it unmaintained. This boilerplate is simply
29+
a more up to date alternative.
30+
31+
## Requirements
32+
* Node > v14
33+
34+
## Getting Started
35+
36+
First clone the repository or use the template option
37+
and place it within your `resources` folder
38+
39+
**Install Dependencies**
40+
41+
Navigate into the newly cloned folder and execute
42+
the following command, to install dependencies.
43+
44+
```sh
45+
npm i
46+
```
47+
48+
## Development
49+
50+
### Hot Building
51+
52+
While developing your resource, this boilerplate offers
53+
a `watch`script that will automatically hot rebuild on any
54+
change within the `client` or `server` directories.
55+
56+
```sh
57+
npm run watch
58+
```
59+
*This script still requires you restart the resource for the
60+
changes to be reflected in-game*
61+
62+
### Entry Points
63+
**Client** - `./client/client.ts`
64+
65+
**Server** - `./server/server.ts`
66+
67+
## Production Build
68+
Once you have completed the development phase of your resource,
69+
you must create an optimized & minimized production build, using
70+
the `build` script.
71+
72+
```sh
73+
npm run build
74+
```
75+
### Automatic Builds (Optional)
76+
*This is not recommended as the embedded version of yarn is
77+
ocassionally prone to performance and environment problems. We
78+
highly recomend, you manually run the build script*
79+
80+
If desired, the `fxmanifest.lua` can be setup to allow for
81+
FXServer to automatically build on resource start. This utilizes
82+
the embedded `yarn` & `webpack` default resources.
83+
84+
To enable this, add the following to your `fxmanifest.lua`
85+
86+
```lua
87+
dependency {
88+
'yarn',
89+
'webpack'
90+
}
91+
92+
webpack_config 'webpack.config.js'
93+
```
94+
95+
### Additional Notes
96+
97+
Need further support? Join our [Discord](https://discord.com/invite/HYwBjTbAY5)!

client/MyOther.client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// We can still use a multifile format,
2+
// while utilizing ESM import syntax.
3+
export const myRandomData = {
4+
randomStuff: true
5+
}

client/client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { myRandomData } from "./MyOther.client";
2+
3+
on('onResourceStart', (resName: string) => {
4+
if (resName === GetCurrentResourceName()) {
5+
console.log(myRandomData)
6+
console.log('TypeScript boilerplate started!')
7+
}
8+
})

client/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"strict": true,
5+
"esModuleInterop": true,
6+
"allowSyntheticDefaultImports": true,
7+
"module": "CommonJS",
8+
"types": ["@citizenfx/client", "@types/node"],
9+
"lib": ["ES2020"]
10+
},
11+
"include": ["./**/*"],
12+
"exclude": ["**/node_modules", "**/__tests__/*"]
13+
}

fxmanifest.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fxversion 'cerulean'
2+
name 'FiveM TypeScript Boilerplate'
3+
author 'Project Error'
4+
game 'gta5'
5+
6+
server_script 'dist/server/**/*.js'
7+
client_script 'dist/client/**/*.js'
8+

0 commit comments

Comments
 (0)