Sfoglia il codice sorgente

HUE-9377 [ui] Reduce webpack config duplication

Johan Ahlen 5 anni fa
parent
commit
41d0f83058

+ 63 - 0
desktop/core/src/desktop/js/webpack/configUtils.js

@@ -0,0 +1,63 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
+const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
+const CleanWebpackPlugin = require('clean-webpack-plugin');
+const RelativeBundleTracker = require('./relativeBundleTracker');
+const RemoveVueAbsolutePathFromMapPlugin = require('./removeVueAbsolutePathFromMapPlugin');
+const webpack = require('webpack');
+const { VueLoaderPlugin } = require('vue-loader');
+
+const BUNDLES = {
+  HUE: 'hue',
+  LOGIN: 'login',
+  WORKERS: 'workers'
+};
+
+const getPluginConfig = (name, withAnalyzer) => {
+  const plugins = [
+    new CleanObsoleteChunks(),
+    new webpack.SourceMapDevToolPlugin({
+      filename: `${name}/[file].map`,
+      publicPath: `/static/desktop/js/bundles/${name}/`,
+      fileContext: 'public'
+    }),
+    new CleanWebpackPlugin([
+      `${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/${name}`
+    ]),
+    new RelativeBundleTracker({
+      path: '.',
+      filename: `webpack-stats${name !== BUNDLES.HUE ? '-' + name : ''}.json`
+    }),
+    new webpack.BannerPlugin(
+      '\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
+    ),
+    new RemoveVueAbsolutePathFromMapPlugin()
+  ];
+  if (withAnalyzer) {
+    plugins.push(new BundleAnalyzerPlugin({ analyzerPort: 9000 }));
+  }
+  if (name !== BUNDLES.WORKERS) {
+    plugins.push(new VueLoaderPlugin());
+  }
+  return plugins;
+};
+
+module.exports = {
+  BUNDLES: BUNDLES,
+  getPluginConfig: getPluginConfig
+};

+ 39 - 0
desktop/core/src/desktop/js/webpack/relativeBundleTracker.js

@@ -0,0 +1,39 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const each = require('lodash/fp/each');
+const BundleTracker = require('webpack-bundle-tracker');
+const path = require('path');
+
+// https://github.com/ezhome/webpack-bundle-tracker/issues/25
+class RelativeBundleTracker extends BundleTracker {
+  convertPathChunks(chunks) {
+    each(
+      each(chunk => {
+        chunk.path = path.relative(this.options.path, chunk.path);
+      })
+    )(chunks);
+  }
+  writeOutput(compiler, contents) {
+    if (contents.status === 'done') {
+      this.convertPathChunks(contents.chunks);
+    }
+
+    super.writeOutput(compiler, contents);
+  }
+}
+
+module.exports = RelativeBundleTracker;

+ 48 - 0
desktop/core/src/desktop/js/webpack/removeVueAbsolutePathFromMapPlugin.js

@@ -0,0 +1,48 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const fs = require('fs');
+
+// Vue generates absolute paths in the .js.map files for vue-hot-reload-api, this replaces it
+// with a relative path.
+class RemoveVueAbsolutePathFromMapPlugin {
+  apply(compiler) {
+    compiler.hooks.afterEmit.tapAsync(
+      'RemoveVueAbsolutePathFromMapPlugin',
+      (compilation, callback) => {
+        compilation.chunks.forEach(chunk => {
+          chunk.files.forEach(filename => {
+            if (/\.js\.map$/.test(filename)) {
+              const source = compilation.assets[filename].source();
+              if (/"[^"]+\/node_modules\/vue-hot-reload-api/.test(source)) {
+                const actualFilename = filename.split('/').pop();
+                const outputFilename = compilation.outputOptions.path + '/' + actualFilename;
+                const cleanSource = source.replace(
+                  /"[^"]+\/node_modules\/vue-hot-reload-api/gi,
+                  '"../../../../../../../../node_modules/vue-hot-reload-api'
+                );
+                fs.writeFileSync(outputFilename, cleanSource);
+              }
+            }
+          });
+        });
+        callback();
+      }
+    );
+  }
+}
+
+module.exports = RemoveVueAbsolutePathFromMapPlugin;

+ 45 - 102
webpack.config.js

@@ -1,98 +1,30 @@
-const webpack = require('webpack');
-const BundleTracker = require('webpack-bundle-tracker');
-const fs = require('fs');
-const CleanWebpackPlugin = require('clean-webpack-plugin');
-const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
-const { VueLoaderPlugin } = require('vue-loader');
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
-const path = require('path');
-const each = require('lodash/fp/each');
-
-// Vue generates absolute paths in the .js.map files for vue-hot-reload-api, this replaces it
-// with a relative path.
-class RemoveVueAbsolutePathFromMapPlugin {
-  apply(compiler) {
-    compiler.hooks.afterEmit.tapAsync(
-      'RemoveVueAbsolutePathFromMapPlugin',
-      (compilation, callback) => {
-        compilation.chunks.forEach(chunk => {
-          chunk.files.forEach(filename => {
-            if (/\.js\.map$/.test(filename)) {
-              const source = compilation.assets[filename].source();
-              if (/"[^"]+\/node_modules\/vue-hot-reload-api/.test(source)) {
-                const actualFilename = filename.split('/').pop();
-                const outputFilename = compilation.outputOptions.path + '/' + actualFilename;
-                const cleanSource = source.replace(
-                  /"[^"]+\/node_modules\/vue-hot-reload-api/gi,
-                  '"../../../../../../../../node_modules/vue-hot-reload-api'
-                );
-                fs.writeFileSync(outputFilename, cleanSource);
-              }
-            }
-          });
-        });
-        callback();
-      }
-    );
-  }
-}
-
-// https://github.com/ezhome/webpack-bundle-tracker/issues/25
-class RelativeBundleTracker extends BundleTracker {
-  convertPathChunks(chunks) {
-    each(
-      each(chunk => {
-        chunk.path = path.relative(this.options.path, chunk.path);
-      })
-    )(chunks);
-  }
-  writeOutput(compiler, contents) {
-    if (contents.status === 'done') {
-      this.convertPathChunks(contents.chunks);
-    }
-
-    super.writeOutput(compiler, contents);
-  }
-}
+const { BUNDLES, getPluginConfig } = require('./desktop/core/src/desktop/js/webpack/configUtils');
 
 module.exports = {
   devtool: false,
-  mode: 'development',
-  performance: {
-    maxEntrypointSize: 400 * 1024, // 400kb
-    maxAssetSize: 400 * 1024 // 400kb
-  },
-  resolve: {
-    extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
-    modules: ['node_modules', 'js'],
-    alias: {
-      bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
-      vue$: __dirname + '/node_modules/vue/dist/vue.esm.browser.min.js'
-    }
-  },
   entry: {
     hue: ['./desktop/core/src/desktop/js/hue.js'],
     notebook: ['./desktop/core/src/desktop/js/apps/notebook/app.js'],
     tableBrowser: ['./desktop/core/src/desktop/js/apps/tableBrowser/app.js'],
     jobBrowser: ['./desktop/core/src/desktop/js/apps/jobBrowser/app.js']
   },
-  optimization: {
-    //minimize: true,
-    minimize: false,
-    splitChunks: {
-      chunks: 'all',
-      automaticNameMaxLength: 90
-    },
-    runtimeChunk: {
-      name: 'hue'
-    }
-  },
-  output: {
-    path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
-    filename: '[name]-bundle-[hash].js',
-    chunkFilename: '[name]-chunk-[hash].js'
-  },
+  mode: 'development',
   module: {
     rules: [
       {
@@ -121,21 +53,32 @@ module.exports = {
       }
     ]
   },
-
-  plugins: [
-    // new BundleAnalyzerPlugin({ analyzerPort: 9000 }),
-    new CleanObsoleteChunks(),
-    new webpack.SourceMapDevToolPlugin({
-      filename: 'hue/[file].map',
-      publicPath: '/static/desktop/js/bundles/hue/',
-      fileContext: 'public'
-    }),
-    new CleanWebpackPlugin([__dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue']),
-    new RelativeBundleTracker({ path: '.', filename: 'webpack-stats.json' }),
-    new webpack.BannerPlugin(
-      '\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
-    ),
-    new VueLoaderPlugin(),
-    new RemoveVueAbsolutePathFromMapPlugin()
-  ]
+  optimization: {
+    //minimize: true,
+    minimize: false,
+    splitChunks: {
+      chunks: 'all'
+    },
+    runtimeChunk: {
+      name: 'hue'
+    }
+  },
+  output: {
+    path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
+    filename: '[name]-bundle-[hash].js',
+    chunkFilename: '[name]-chunk-[hash].js'
+  },
+  performance: {
+    maxEntrypointSize: 400 * 1024, // 400kb
+    maxAssetSize: 400 * 1024 // 400kb
+  },
+  plugins: getPluginConfig(BUNDLES.HUE),
+  resolve: {
+    extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
+    modules: ['node_modules', 'js'],
+    alias: {
+      bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
+      vue$: __dirname + '/node_modules/vue/dist/vue.esm.browser.min.js'
+    }
+  }
 };

+ 25 - 118
webpack.config.login.js

@@ -1,131 +1,38 @@
-const webpack = require('webpack');
-const BundleTracker = require('webpack-bundle-tracker');
-const fs = require('fs');
-const CleanWebpackPlugin = require('clean-webpack-plugin');
-const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
-const { VueLoaderPlugin } = require('vue-loader');
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
-const path = require('path');
-const each = require('lodash/fp/each');
-
-// Vue generates absolute paths in the .js.map files for vue-hot-reload-api, this replaces it
-// with a relative path.
-class RemoveVueAbsolutePathFromMapPlugin {
-  apply(compiler) {
-    compiler.hooks.afterEmit.tapAsync(
-      'RemoveVueAbsolutePathFromMapPlugin',
-      (compilation, callback) => {
-        compilation.chunks.forEach(chunk => {
-          chunk.files.forEach(filename => {
-            if (/\.js\.map$/.test(filename)) {
-              const source = compilation.assets[filename].source();
-              if (/"[^"]+\/node_modules\/vue-hot-reload-api/.test(source)) {
-                const actualFilename = filename.split('/').pop();
-                const outputFilename = compilation.outputOptions.path + '/' + actualFilename;
-                const cleanSource = source.replace(
-                  /"[^"]+\/node_modules\/vue-hot-reload-api/gi,
-                  '"../../../../../../../../node_modules/vue-hot-reload-api'
-                );
-                fs.writeFileSync(outputFilename, cleanSource);
-              }
-            }
-          });
-        });
-        callback();
-      }
-    );
-  }
-}
-
-// https://github.com/ezhome/webpack-bundle-tracker/issues/25
-class RelativeBundleTracker extends BundleTracker {
-  convertPathChunks(chunks) {
-    each(
-      each(chunk => {
-        chunk.path = path.relative(this.options.path, chunk.path);
-      })
-    )(chunks);
-  }
-  writeOutput(compiler, contents) {
-    if (contents.status === 'done') {
-      this.convertPathChunks(contents.chunks);
-    }
-
-    super.writeOutput(compiler, contents);
-  }
-}
+const { BUNDLES, getPluginConfig } = require('./desktop/core/src/desktop/js/webpack/configUtils');
+const shared = require('./webpack.config');
 
 module.exports = {
-  devtool: false,
-  mode: 'development',
-  performance: {
-    maxEntrypointSize: 400 * 1024, // 400kb
-    maxAssetSize: 400 * 1024 // 400kb
-  },
-  resolve: {
-    extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
-    modules: ['node_modules', 'js'],
-    alias: {
-      bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js',
-      vue$: __dirname + '/node_modules/vue/dist/vue.esm.browser.min.js'
-    }
-  },
+  devtool: shared.devtool,
   entry: {
     login: ['./desktop/core/src/desktop/js/login.js']
   },
+  mode: shared.mode,
+  module: shared.module,
+  performance: shared.performance,
   optimization: {
     minimize: true,
-    splitChunks: {
-      automaticNameMaxLength: 90
-    }
+    splitChunks: {}
   },
   output: {
     path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/login',
-    filename: '[name]-bundle-[hash].js'
-  },
-  module: {
-    rules: [
-      { test: /\.tsx?$/, loader: 'babel-loader' },
-      { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre' },
-      { test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
-      { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
-      { test: /\.css$/, loader: 'style-loader!css-loader' },
-      { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
-      {
-        test: /\.jsx?$/,
-        exclude: /node_modules/,
-        loader: 'babel-loader'
-      },
-      { include: /\.json$/, loaders: ['json-loader'] },
-      {
-        test: /\.vue$/,
-        loader: 'vue-loader',
-        options: {
-          loaders: {
-            less: ['vue-style-loader', 'css-loader', 'less-loader']
-          }
-        }
-      }
-    ]
+    filename: shared.output.filename
   },
-
-  plugins: [
-    // new BundleAnalyzerPlugin({ analyzerPort: 9000 }),
-    new CleanObsoleteChunks(),
-    new webpack.SourceMapDevToolPlugin({
-      filename: 'login/[file].map',
-      publicPath: '/static/desktop/js/bundles/login/',
-      fileContext: 'public'
-    }),
-    new CleanWebpackPlugin([
-      __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/login'
-    ]),
-    new RelativeBundleTracker({ path: '.', filename: 'webpack-stats-login.json' }),
-    new webpack.BannerPlugin(
-      '\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
-    ),
-    new VueLoaderPlugin(),
-    new RemoveVueAbsolutePathFromMapPlugin()
-  ]
+  plugins: getPluginConfig(BUNDLES.LOGIN),
+  resolve: shared.resolve
 };

+ 26 - 105
webpack.config.workers.js

@@ -1,121 +1,42 @@
-const webpack = require('webpack');
-const BundleTracker = require('webpack-bundle-tracker');
-const fs = require('fs');
-const CleanWebpackPlugin = require('clean-webpack-plugin');
-const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
-const path = require('path');
-const each = require('lodash/fp/each');
-
-// Vue generates absolute paths in the .js.map files for vue-hot-reload-api, this replaces it
-// with a relative path.
-class RemoveVueAbsolutePathFromMapPlugin {
-  apply(compiler) {
-    compiler.hooks.afterEmit.tapAsync(
-      'RemoveVueAbsolutePathFromMapPlugin',
-      (compilation, callback) => {
-        compilation.chunks.forEach(chunk => {
-          chunk.files.forEach(filename => {
-            if (/\.js\.map$/.test(filename)) {
-              const source = compilation.assets[filename].source();
-              if (/"[^"]+\/node_modules\/vue-hot-reload-api/.test(source)) {
-                const actualFilename = filename.split('/').pop();
-                const outputFilename = compilation.outputOptions.path + '/' + actualFilename;
-                const cleanSource = source.replace(
-                  /"[^"]+\/node_modules\/vue-hot-reload-api/gi,
-                  '"../../../../../../../../node_modules/vue-hot-reload-api'
-                );
-                fs.writeFileSync(outputFilename, cleanSource);
-              }
-            }
-          });
-        });
-        callback();
-      }
-    );
-  }
-}
-
-// https://github.com/ezhome/webpack-bundle-tracker/issues/25
-class RelativeBundleTracker extends BundleTracker {
-  convertPathChunks(chunks) {
-    each(
-      each(chunk => {
-        chunk.path = path.relative(this.options.path, chunk.path);
-      })
-    )(chunks);
-  }
-  writeOutput(compiler, contents) {
-    if (contents.status === 'done') {
-      this.convertPathChunks(contents.chunks);
-    }
-
-    super.writeOutput(compiler, contents);
-  }
-}
+const { BUNDLES, getPluginConfig } = require('./desktop/core/src/desktop/js/webpack/configUtils');
+const shared = require('./webpack.config');
 
 module.exports = {
-  devtool: false,
-  mode: 'development',
+  devtool: shared.devtool,
+  mode: shared.mode,
   target: 'webworker',
-  performance: {
-    maxEntrypointSize: 400 * 1024, // 400kb
-    maxAssetSize: 400 * 1024 // 400kb
-  },
-  resolve: {
-    extensions: ['.json', '.jsx', '.js', '.tsx', '.ts'],
-    modules: ['node_modules', 'js'],
-    alias: {
-      bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js'
-    }
-  },
+  performance: shared.performance,
+  resolve: shared.resolve,
   entry: {
     sqlLocationWebWorker: ['./desktop/core/src/desktop/js/sql/sqlLocationWebWorker.js'],
     sqlSyntaxWebWorker: ['./desktop/core/src/desktop/js/sql/sqlSyntaxWebWorker.js']
   },
   optimization: {
-    //minimize: true
     minimize: false,
-    splitChunks: {
-      automaticNameMaxLength: 90
-    }
+    splitChunks: {}
   },
   output: {
     path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/workers',
-    filename: '[name]-bundle-[hash].js',
-    chunkFilename: '[name]-chunk-[hash].js',
+    filename: shared.output.filename,
+    chunkFilename: shared.output.chunkFilename,
     globalObject: 'this'
   },
-  module: {
-    rules: [
-      { test: /\.tsx?$/, loader: 'babel-loader' },
-      { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre' },
-      { test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
-      { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
-      { test: /\.css$/, loader: 'style-loader!css-loader' },
-      { test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
-      {
-        test: /\.jsx?$/,
-        exclude: /node_modules/,
-        loader: 'babel-loader'
-      }
-    ]
-  },
-
-  plugins: [
-    new CleanObsoleteChunks(),
-    new webpack.SourceMapDevToolPlugin({
-      filename: 'workers/[file].map',
-      publicPath: '/static/desktop/js/bundles/workers/',
-      fileContext: 'public'
-    }),
-    new CleanWebpackPlugin([
-      __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/workers/'
-    ]),
-    new RelativeBundleTracker({ path: '.', filename: 'webpack-stats-workers.json' }),
-    new webpack.BannerPlugin(
-      '\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
-    ),
-    new RemoveVueAbsolutePathFromMapPlugin()
-  ]
+  module: shared.module,
+  plugins: getPluginConfig(BUNDLES.WORKERS)
 };