Skip to content

Instantly share code, notes, and snippets.

@boydaihungst
Last active April 26, 2023 01:24
Show Gist options
  • Save boydaihungst/6d449170ea5efb31005ef60722be32bf to your computer and use it in GitHub Desktop.
Save boydaihungst/6d449170ea5efb31005ef60722be32bf to your computer and use it in GitHub Desktop.
Debug Nodejs, typescript, nodemon, webpack, vscode
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "WatchDebug",
"port": 9229,
"restart": true,
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
"name": "WatchBuild",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/webpack/bin/webpack.js",
"args": ["--watch"],
"sourceMaps": true,
"restart": true,
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Testing",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": ["--watch"],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
}
],
"compounds": [
{
"name": "run debug",
"configurations": ["WatchBuild", "WatchDebug"]
}
]
}
"scripts": {
"build": "webpack",
"watch:dev": "cross-env NODE_ENV=development webpack --watch",
"run:dev": "cross-env NODE_ENV=development nodemon dist/index.js",
"test": "cross-env NODE_ENV=test jest --watch",
"lint": "eslint --ext .ts,.js --ignore-path .gitignore . --fix"
}
module.exports = {
entry: './src/index.ts',
mode: NODE_ENV,
devtool: NODE_ENV === 'development' ? 'source-map' : '',
target: 'node',
externals: [nodeExternals()],
output: {
path: resolve(__dirname, 'dist'),
filename: 'index.js',
},
resolve: {
extensions: ['.ts', '.js'],
},
plugins: [
// new WebpackShellPlugin({
// onBuildExit: {
// scripts: ['yarn test'],
// blocking: true,
// parallel: false,
// },
// }),
new NodemonPlugin({
script: './dist/index.js',
watch: [resolve(__dirname, 'dist')],
ignore: ['*.js.map'],
verbose: true,
ext: 'js,json',
nodeArgs: ['--inspect'],
}),
],
module: {
rules: [
{
test: /\.ts?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
emitWarning: true,
emitError: true,
configFile: './.eslintrc.json',
fix: true,
},
},
{
test: /\.ts$/,
use: ['ts-loader'],
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment