Browse Source

HUE-9425 [ui] Fix issue with the CleanWebpackPlugin trying to clean the wrong folder

It needs to be declared in the root build folder.
Johan Ahlen 5 years ago
parent
commit
fdf029bf1e

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

@@ -16,7 +16,6 @@
 
 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');
@@ -36,9 +35,6 @@ const getPluginConfig = (name, withAnalyzer) => {
       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`

+ 4 - 1
webpack.config.js

@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+const CleanWebpackPlugin = require('clean-webpack-plugin');
 const {
   BUNDLES,
   getPluginConfig,
@@ -79,7 +80,9 @@ module.exports = {
     maxEntrypointSize: 400 * 1024, // 400kb
     maxAssetSize: 400 * 1024 // 400kb
   },
-  plugins: getPluginConfig(BUNDLES.HUE),
+  plugins: getPluginConfig(BUNDLES.HUE).concat([
+    new CleanWebpackPlugin([`${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/hue`])
+  ]),
   resolve: {
     extensions: ['.json', '.jsx', '.js', '.tsx', '.ts', '.vue'],
     modules: ['node_modules', 'js'],

+ 6 - 1
webpack.config.login.js

@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+const CleanWebpackPlugin = require('clean-webpack-plugin');
 const {
   BUNDLES,
   getPluginConfig,
@@ -39,6 +40,10 @@ module.exports = {
     path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/login',
     filename: shared.output.filename
   },
-  plugins: getPluginConfig(BUNDLES.LOGIN),
+  plugins: getPluginConfig(BUNDLES.LOGIN).concat([
+    new CleanWebpackPlugin([
+      `${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/login`
+    ])
+  ]),
   resolve: shared.resolve
 };

+ 6 - 1
webpack.config.workers.js

@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+const CleanWebpackPlugin = require('clean-webpack-plugin');
 const {
   BUNDLES,
   getPluginConfig,
@@ -44,5 +45,9 @@ module.exports = {
     globalObject: 'this'
   },
   module: shared.module,
-  plugins: getPluginConfig(BUNDLES.WORKERS)
+  plugins: getPluginConfig(BUNDLES.WORKERS).concat([
+    new CleanWebpackPlugin([
+      `${__dirname}/desktop/core/src/desktop/static/desktop/js/bundles/workers`
+    ])
+  ])
 };