ojet.config.js 1.5 KB

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