ojet.config.js 1.5 KB

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