1
0
Fork 0

Auto stash before revert of "gitflow-feature-stash: init-template"

develop
naicoi 2023-04-21 02:06:10 +07:00
parent 1f52295d46
commit fd8618acc1
Signed by: naicoi
GPG Key ID: 7142E472DF7CF7D9
7 changed files with 104 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
node_modules
.env
dist
yarn.lock

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "nodejs-typescript-webpack",
"version": "0.1.0",
"main": "index.js",
"repository": "git@ssh.techio.dev:template/nodejs-typescript-webpack.git",
"author": "naicoi <naicoi@lttech.vn>",
"license": "MIT",
"scripts": {
"dev": "pm2-runtime pm2.development.json",
"build": "webpack"
},
"devDependencies": {
"@tsconfig/node18": "1.0.1",
"@types/node": "18.15.3",
"copy-webpack-plugin": "11.0.0",
"pm2": "5.3.0",
"ts-loader": "9.4.2",
"ts-node": "10.9.1",
"typescript": "4.9.5",
"webpack": "5.75.0",
"webpack-cli": "5.0.1",
"webpack-node-externals": "3.0.0"
}
}

15
pm2.development.json Normal file
View File

@ -0,0 +1,15 @@
{
"apps": [
{
"name": "development",
"script": "./src/index.ts",
"watch": ["src"],
"exec_mode": "fork",
"watch_delay": 1000,
"ignore_watch": ["node_modules", "prisma"],
"env": {
"NODE_ENV": "development"
}
}
]
}

14
pm2.production.json Normal file
View File

@ -0,0 +1,14 @@
{
"apps": [
{
"name": "nodejs-typescript-webpack",
"script": "main.js",
"instances": "max",
"exec_mode": "cluster",
"max_memory_restart": "1G",
"env": {
"NODE_ENV": "production"
}
}
]
}

3
src/index.ts Normal file
View File

@ -0,0 +1,3 @@
process.on("SIGINT", function () {
console.log(`SIGINT`);
});

5
tsconfig.json Normal file
View File

@ -0,0 +1,5 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"include": ["./src/**/*.ts"],
"exclude": ["./node_modules"]
}

39
webpack.config.js Normal file
View File

@ -0,0 +1,39 @@
const nodeExternals = require("webpack-node-externals");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const config = {
entry: "./src/index.ts",
mode: "production",
target: "node",
module: {
rules: [{ test: /\.ts$/, use: ["ts-loader"], exclude: /node_modules/ }],
},
resolve: {
extensions: [".ts"],
},
externalsPresets: { node: true },
externals: [nodeExternals()],
output: {
clean: true,
filename: "main.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "production.json"),
},
{
from: path.resolve(__dirname, "package.json"),
},
{
from: path.resolve(__dirname, "yarn.lock"),
},
],
}),
],
};
module.exports = config;