Skip to content

Instantly share code, notes, and snippets.

@jh0l
Created December 7, 2020 17:59
Show Gist options
  • Save jh0l/862c9077e011a3e3007a9745a7c81d05 to your computer and use it in GitHub Desktop.
Save jh0l/862c9077e011a3e3007a9745a7c81d05 to your computer and use it in GitHub Desktop.
Code examples in `Bundling your JS/TypeScript Node.js modules code withWebpack`
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"outDir": "server-build",
"target": "es2016"
},
"include": ["src"]
}
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
target: 'node',
externals: [nodeExternals()], // removes node_modules from your final bundle
entry: './build/server/index.js', // make sure this matches the main root of your code
output: {
path: path.join(__dirname, 'bundle'), // this can be any path and directory you want
filename: 'bundle.js',
},
optimization: {
minimize: false, // enabling this reduces file size and readability
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment