ojet.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 webpack = require("webpack");
  7. const package = require("./package.json");
  8. module.exports = {
  9. /**
  10. *
  11. * @param {object} options.context - ojet build context which contains useful fields like
  12. * buildType
  13. * @param {object} options.config - Default webpack config generated by ojet. You can
  14. * add to it, remove from it or update it using webpack-merge which was
  15. * installed alongside webpack. If desired, you can create your own config
  16. * and return it which will override the default config
  17. * @returns {object|undefined}
  18. */
  19. webpack: ({ context, config }) => {
  20. if (context.buildType === 'release') {
  21. // update config with release / production options
  22. } else {
  23. // update config with development options
  24. config.devServer = {
  25. ...config.devServer,
  26. https: process.env.HTTPS === "true",
  27. port: 8001,
  28. allowedHosts: [
  29. "localhost",
  30. package.config.hostPluginA,
  31. package.config.hostDashboard
  32. ]
  33. };
  34. config.plugins.push(new webpack.DefinePlugin({
  35. APP_NAME: JSON.stringify(process.env.APP_NAME)
  36. }));
  37. }
  38. // only have to return if new config object was created but
  39. // since it doesn't matter always returning the config is good
  40. // practice
  41. return config;
  42. }
  43. };