Feat: 新增Webpack构建打包

This commit is contained in:
Suwings 2022-07-17 17:38:50 +08:00
parent 3c0b454355
commit ff5d98122f
4 changed files with 817 additions and 5 deletions

3
.gitignore vendored
View File

@ -17,8 +17,7 @@ data/
dist/
out/
public/
production/
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

797
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
"scripts": {
"dev": "nodemon app.js",
"start": "ts-node ./src/app.ts",
"build": "tsc"
"build": "tsc && webpack --config webpack.config.js"
},
"homepage": "https://mcsmanager.com/",
"author": "https://github.com/Suwings",
@ -47,6 +47,9 @@
"@types/uuid": "^8.3.0",
"eslint": "^7.23.0",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"typescript": "^4.2.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^3.0.0"
}
}

15
webpack.config.js Normal file
View File

@ -0,0 +1,15 @@
/* eslint-disable no-undef */
const path = require('path');
const nodeExternals = require('webpack-node-externals')
module.exports = {
mode: "production",
entry: './dist/app.js',
target: 'node',
externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
output: {
filename: 'app.js',
path: path.resolve(__dirname, 'production'),
},
};