You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

validate-options.js 604B

123456789101112131415161718192021
  1. const webpackConfigurationSchema = require("../config/webpackConfigurationSchema.json");
  2. const validateSchema = require("webpack").validateSchema;
  3. module.exports = function validateOptions(options) {
  4. let error;
  5. try {
  6. const errors = validateSchema(webpackConfigurationSchema, options);
  7. if (errors && errors.length > 0) {
  8. const { WebpackOptionsValidationError } = require("webpack");
  9. error = new WebpackOptionsValidationError(errors);
  10. }
  11. } catch (err) {
  12. error = err;
  13. }
  14. if (error) {
  15. console.error(error.message);
  16. // eslint-disable-next-line no-process-exit
  17. process.exit(-1);
  18. }
  19. };