Created
December 7, 2020 17:59
-
-
Save jh0l/862c9077e011a3e3007a9745a7c81d05 to your computer and use it in GitHub Desktop.
Code examples in `Bundling your JS/TypeScript Node.js modules code withWebpack`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"esModuleInterop": true, | |
"outDir": "server-build", | |
"target": "es2016" | |
}, | |
"include": ["src"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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