get-webpack-version.js 563 B

1234567891011121314151617
  1. // eslint-disable-next-line import/no-extraneous-dependencies
  2. const webpackVersion = require('webpack/package.json').version;
  3. /**
  4. * @param {boolean} [onlyMajor=true]
  5. * @return {string}
  6. */
  7. function getWebpackVersion(onlyMajor = true) {
  8. return onlyMajor ? webpackVersion.split('.')[0] : webpackVersion;
  9. }
  10. getWebpackVersion.IS_1 = getWebpackVersion() === '1';
  11. getWebpackVersion.IS_2 = getWebpackVersion() === '2';
  12. getWebpackVersion.IS_3 = getWebpackVersion() === '3';
  13. getWebpackVersion.IS_4 = getWebpackVersion() === '4';
  14. module.exports = getWebpackVersion;