/** 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 package = require("./package.json"); 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 config.devServer = { ...config.devServer, https: process.env.HTTPS === "true", port: 8001, allowedHosts: [ "localhost", package.config.hostPluginA, package.config.hostDashboard ] }; config.plugins.push(new webpack.DefinePlugin({ APP_NAME: JSON.stringify(process.env.APP_NAME) })); } // 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; } };