This is the example webpack.config.js
on https://webpack.js.org/:
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
}
Why is entry
a relative file path and output
an object with an absolute directory path and filename? Make them consistent:
module.exports = {
entry: './src/index.js',
output: './dist/bundle.js'
}
// Or
module.exports = {
entry: {
path: path.resolve(__dirname, 'src')
filename: 'index.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
}
Both entry
and output
are reasonable option names, but their relationship is unclear. Antonyms would be better:
module.exports = {
entry: './src/index.js',
exit: './dist/bundle.js'
}
// Or
module.exports = {
enter: './src/index.js',
exit: './dist/bundle.js'
}
// Or
module.exports = {
input: './src/index.js',
output: './dist/index.js'
}