Browse Source

HUE-9458 [ui] UI-build - Enable extending of webpack config for custom builds

sreenaths 5 years ago
parent
commit
d1533b0d93
2 changed files with 18 additions and 7 deletions
  1. 6 6
      package.json
  2. 12 1
      webpack.config.js

+ 6 - 6
package.json

@@ -140,13 +140,13 @@
   },
   "scripts": {
     "devinstall": "npm cache clean && npm install && npm prune",
-    "webpack": "webpack --config ${HUE_WEBPACK_CONFIG:-webpack.config.js}",
-    "webpack-login": "webpack --config ${HUE_WEBPACK_CONFIG_LOGIN:-webpack.config.login.js}",
-    "webpack-workers": "webpack --config ${HUE_WEBPACK_CONFIG_WORKERS:-webpack.config.workers.js}",
-    "webpack-npm": "webpack --config ${HUE_WEBPACK_CONFIG_NPM:-webpack.config.npm.js}",
+    "webpack": "webpack --config webpack.config.js",
+    "webpack-login": "webpack --config webpack.config.login.js",
+    "webpack-workers": "webpack --config webpack.config.workers.js",
+    "webpack-npm": "webpack --config webpack.config.npm.js",
     "publish-gethue": "npm run webpack-npm && cd npm_dist && npm publish",
-    "dev": "webpack --watch --config ${HUE_WEBPACK_CONFIG:-webpack.config.js} -d",
-    "dev-workers": "webpack --config ${HUE_WEBPACK_CONFIG_WORKERS:-webpack.config.workers.js} --watch -d",
+    "dev": "webpack --watch --config webpack.config.js -d",
+    "dev-workers": "webpack --config webpack.config.workers.js --watch -d",
     "less": "./node_modules/.bin/grunt less",
     "less-dev": "./node_modules/.bin/grunt watch",
     "less-lint": "stylelint \"desktop/core/src/desktop/static/desktop/less/**/*.less\"",

+ 12 - 1
webpack.config.js

@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+const fs = require('fs');
 const CleanWebpackPlugin = require('clean-webpack-plugin');
 const {
   BUNDLES,
@@ -21,7 +22,7 @@ const {
   splitChunksName
 } = require('./desktop/core/src/desktop/js/webpack/configUtils');
 
-module.exports = {
+const config = {
   devtool: false,
   entry: {
     hue: ['./desktop/core/src/desktop/js/hue.js'],
@@ -92,3 +93,13 @@ module.exports = {
     }
   }
 };
+
+// To customize build configurations
+const EXTEND_CONFIG_FILE = './webpack.config.extend.js';
+if (fs.existsSync(EXTEND_CONFIG_FILE)) {
+  const endedConfig = require(EXTEND_CONFIG_FILE);
+  endedConfig(config);
+  console.info('Webpack extended!');
+}
+
+module.exports = config;