Konubinix' opinionated web of thoughts

Webpack

Fleeting

target

target string [string] false

Instructs webpack to generate runtime code for a specific environment. Note that webpack runtime code is not the same as the user code you write, you should transpile those code with transpilers like Babel if you want to target specific environments, e.g, you have arrow functions in source code and want to run the bundled code in ES5 environments. Webpack won’t transpile them automatically with a target configured

https://webpack.js.org/configuration/target/

multiple targets

you can create an isomorphic library by bundling two separate configurations:

webpack.config.js

const path = require(‘path’); const serverConfig = { target: ’node’, output: { path: path.resolve(__dirname, ‘dist’), filename: ’lib.node.js’, }, //… };

const clientConfig = { target: ‘web’, // <=== can be omitted as default is ‘web’ output: { path: path.resolve(__dirname, ‘dist’), filename: ’lib.js’, }, //… };

module.exports = [serverConfig, clientConfig]; The example above will create a lib.js and lib.node.js file in your dist folder.

https://webpack.js.org/concepts/targets/

output.globalObject

Notes linking here