/** Copyright (c) 2015, 2022, Oracle and/or its affiliates. Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/ */ const webpack = require("webpack"); const merge = require("webpack-merge").merge; const package = require("./package.json"); const developmentConfig = { plugins: [ new webpack.DefinePlugin({ API_PATH: JSON.stringify(process.env.API_PATH) }) ], devServer: { https: process.env.HTTPS === "true", port: 8000, allowedHosts: [ "localhost", package.config.host ], historyApiFallback: true, proxy: { "/api": { target: process.env.API_URL || "http://localhost:3000", pathRewrite: { "^/api": process.env.API_PATH || "" } }, } } }; module.exports = { /** * * @param {object} options.context - ojet build context which contains useful fields like * buildType * @param {object} options.config - Default webpack config generated by ojet. You can * add to it, remove from it or update it using webpack-merge which was * installed alongside webpack. If desired, you can create your own config * and return it which will override the default config * @returns {object|undefined} */ webpack: ({ context, config }) => { if (context.buildType === "release") { // update config with release / production options } else { // update config with development options return merge(config, developmentConfig); } // only have to return if new config object was created but // since it doesn't matter always returning the config is good // practice return config; } };