ojet.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. Copyright (c) 2015, 2022, Oracle and/or its affiliates.
  3. Licensed under The Universal Permissive License (UPL), Version 1.0
  4. as shown at https://oss.oracle.com/licenses/upl/
  5. */
  6. const package = require("./package.json");
  7. const merge = require("webpack-merge").merge;
  8. const developmentConfig = {
  9. devServer: {
  10. https: false,
  11. port: 8000,
  12. allowedHosts: [
  13. "localhost",
  14. package.config.host
  15. ]
  16. }
  17. };
  18. module.exports = {
  19. /**
  20. *
  21. * @param {object} options.context - ojet build context which contains useful fields like
  22. * buildType
  23. * @param {object} options.config - Default webpack config generated by ojet. You can
  24. * add to it, remove from it or update it using webpack-merge which was
  25. * installed alongside webpack. If desired, you can create your own config
  26. * and return it which will override the default config
  27. * @returns {object|undefined}
  28. */
  29. webpack: ({ context, config }) => {
  30. if (context.buildType === "release") {
  31. // update config with release / production options
  32. } else {
  33. // update config with development options
  34. return merge(config, developmentConfig);
  35. }
  36. // only have to return if new config object was created but
  37. // since it doesn't matter always returning the config is good
  38. // practice
  39. return config;
  40. }
  41. };