Skip to content

Commit 87e5901

Browse files
committed
Added readme.md, updated version to 1.0.0
1 parent ebd5bc4 commit 87e5901

File tree

2 files changed

+163
-2
lines changed

2 files changed

+163
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-webpack-template",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "A typescript webpack template for hot reload script development.",
55
"main": "index.ts",
66
"scripts": {

readme.md

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,162 @@
1-
# Typescript Webpack Template
1+
![Header](https://h4hn.de/hot/github/typescript-webpack-template-banner.png)
2+
3+
## Installation
4+
### Quick Setup:
5+
Simply click on the use template button and initialize your git repository.
6+
Clone your respository to your device and initialize it with:
7+
8+
```
9+
yarn install
10+
```
11+
12+
### Traditional way:
13+
Alternatively you can clone it via git. After, that just install the dependencies via yarn.
14+
15+
```
16+
# Clone the repository
17+
$ git clone https://github.com/teck-digital/typescript-webpack-template
18+
19+
# Go into the repository
20+
$ cd typescript-webpack-config
21+
22+
# Install dependencies
23+
$ yarn install
24+
```
25+
26+
## Usage
27+
28+
There are four ways you can compile and run your code:
29+
30+
### Development
31+
```
32+
yarn dev
33+
```
34+
35+
This will start a watch run, which watches for any file changes and then
36+
recompiles. **After every compilation, the index.js file will be executed.**
37+
38+
39+
### Production Test
40+
```
41+
yarn prod
42+
```
43+
44+
This will compile your code production ready and execute the index.js file.
45+
46+
47+
### Bundling your application
48+
49+
```
50+
yarn build
51+
```
52+
53+
This will compile your code production ready.
54+
55+
### Starting the app
56+
57+
```
58+
yarn start
59+
```
60+
This will, by default, start your application using the _dist/index.js_ entrypoint.
61+
62+
**Important:** You need to have your application built before this script is effective.
63+
If you want to save some time use `yarn prod`!
64+
65+
66+
## Using NPM
67+
68+
If you prefer using npm over yarn, you are free to do so.
69+
There are two modifications you will have to make in order for it to work:
70+
71+
### 1. Delete yarn.lock
72+
73+
First, you should delete the `yarn.lock` file in your root directory, as it may
74+
confuse editors or your computer into using yarn.
75+
76+
### 2. Install via npm
77+
78+
Now, install the dependencies and execute scripts via npm instead of yarn:
79+
80+
```
81+
# Install dependencies
82+
$ npm install
83+
84+
# Start development run
85+
$ npm run dev
86+
```
87+
88+
## Automated script exececution
89+
90+
### Modifying executed file
91+
92+
By default, when webpack config contains only one output file that file will be run.
93+
If more files are present, then a file named server.js or index.js (whichever exists) will be run.
94+
If you need to modify this, you can pass in the following option to your webpack config:
95+
96+
```javascript
97+
// config/webpack.config.dev.js
98+
99+
...
100+
101+
plugins: [
102+
plugins: [new RunNodeWebpackPlugin({scriptToRun: "yourScript.js"}), ...],
103+
],
104+
105+
...
106+
```
107+
108+
For more options see https://www.npmjs.com/package/run-node-webpack-plugin
109+
110+
#### Updating package.json
111+
112+
You have now successfully modified the webpack config. For production builds, however,
113+
webpack is out of the game and node manually executes the compiled javascript file.
114+
You will have to update the `prod` and `start` script in your package.json accordingly:
115+
116+
```json
117+
// package.json
118+
119+
"scripts": {
120+
"start": "node dist/yourScript.js",
121+
"prod": "... && node dist/yourScript.js",
122+
},
123+
```
124+
125+
### Opting out
126+
If you want webpack to stop automatically executing your script after every
127+
development build, you can remove the `RunNodeWebpackPlugin` like so:
128+
129+
130+
```javascript
131+
// config/webpack.config.dev.js
132+
133+
-- const RunNodeWebpackPlugin = require("run-node-webpack-plugin");
134+
135+
...
136+
137+
-- plugins: [new RunNodeWebpackPlugin(), new ESLintPlugin({extensions: ['js', 'ts']})],
138+
++ plugins: [new ESLintPlugin({extensions: ['js', 'ts']})],
139+
140+
...
141+
```
142+
143+
You may also want to remove the package from your dependencies afterwards:
144+
```
145+
yarn remove run-node-webpack-plugin
146+
```
147+
148+
**Important:** You will most likely have to update your package.json scripts too,
149+
if you want to opt out entirely. See [Updating package.json](#updating-package.json).
150+
151+
152+
## Contributing
153+
If you'd like to make this project better, more general or add a feature, feel free to open up
154+
a pull request. I am open to any new idea!
155+
156+
## Issues
157+
Feel free to open an issue for any problem you encounter. I will try to help you
158+
as soon as possible.
159+
160+
## License
161+
162+
This project is [MIT licensed](LICENSE).

0 commit comments

Comments
 (0)