Skip to content

Commit b951912

Browse files
committed
Configure webpack for build
1 parent 633f938 commit b951912

File tree

5 files changed

+935
-49
lines changed

5 files changed

+935
-49
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
package-lock.json
3-
output
3+
webpack-output

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"main": "index.js",
1414
"scripts": {
1515
"test": "echo \"Error: No tests specified\"",
16-
"prepare": "rollup -c"
16+
"webpack-build": "webpack"
1717
},
1818
"bin": {
1919
"server": "./output/server.js",
@@ -29,15 +29,18 @@
2929
"@types/yargs": "^17.0.1",
3030
"chokidar": "^3.5.2",
3131
"localtunnel": "^2.0.1",
32-
"rollup": "^2.52.7",
3332
"rxjs": "^7.1.0",
3433
"shelljs": "^0.8.4",
3534
"socket.io": "^4.1.2",
3635
"socket.io-client": "^4.1.2",
36+
"webpack": "^5.42.0",
37+
"webpack-node-externals": "^3.0.0",
3738
"yargs": "^17.0.1"
3839
},
3940
"devDependencies": {
41+
"node-loader": "^2.0.0",
42+
"ts-loader": "^9.2.3",
4043
"typescript": "^4.3.4",
41-
"@rollup/plugin-typescript": "^8.2.1"
44+
"webpack-cli": "^4.7.2"
4245
}
4346
}

rollup.config.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

webpack.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const nodeExternals = require('webpack-node-externals');
2+
3+
module.exports = {
4+
mode: "production",
5+
entry: {
6+
client: "./client.ts",
7+
server: "./server.ts",
8+
},
9+
output: {
10+
filename: "[name].js",
11+
path: __dirname + "/webpack-output/",
12+
},
13+
target: "node",
14+
resolve: {
15+
// Add `.ts` and `.tsx` as a resolvable extension.
16+
extensions: [".ts", ".tsx", ".js", ".node"],
17+
},
18+
module: {
19+
rules: [
20+
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
21+
{ test: /\.tsx?$/, loader: "ts-loader" },
22+
{
23+
test: /.node$/,
24+
loader: "node-loader",
25+
},
26+
],
27+
},
28+
externals: [nodeExternals()],
29+
};

0 commit comments

Comments
 (0)