lotype
lotype

Reputation: 613

How to get the webpack version at build time

During the execution of the webpack build I would like to get the webpack version. I need this info to make build preparations based on webpack 4 or webpack 5.

Intention: to prepare the project for an upgrade from webpack 4 to 5 I am not allowed to make this specific step myself. At some point the company build runner updates webpack.

I know that webpack has a command for it: npx webpack --version. How to access the version from within the build config?

Upvotes: 0

Views: 449

Answers (1)

lotype
lotype

Reputation: 613

To access the webpack version from within the build config it is possible to load webpack as a dependency and check its version property:

const { version } = require('webpack');

Upvotes: 1

Related Questions