Explorar o código

Allow custom webpack config for federated extensions

Jeremy Tuloup %!s(int64=4) %!d(string=hai) anos
pai
achega
b3e3880fda
Modificáronse 1 ficheiros con 34 adicións e 25 borrados
  1. 34 25
      builder/src/extensionConfig.ts

+ 34 - 25
builder/src/extensionConfig.ts

@@ -194,33 +194,42 @@ function generateConfig({
     }
   }
 
+  const customConfigPath = path.join(packagePath, 'webpack.config.js');
+  let customWebpackConfig = {};
+  if (fs.existsSync(customConfigPath)) {
+    customWebpackConfig = require(customConfigPath);
+  }
   const config = [
-    merge(baseConfig, {
-      mode,
-      devtool,
-      entry: {},
-      output: {
-        filename: '[name].[contenthash].js',
-        path: outputPath,
-        publicPath: staticUrl || 'auto'
-      },
-      module: {
-        rules: [{ test: /\.html$/, use: 'file-loader' }]
+    merge(
+      baseConfig,
+      {
+        mode,
+        devtool,
+        entry: {},
+        output: {
+          filename: '[name].[contenthash].js',
+          path: outputPath,
+          publicPath: staticUrl || 'auto'
+        },
+        module: {
+          rules: [{ test: /\.html$/, use: 'file-loader' }]
+        },
+        plugins: [
+          new ModuleFederationPlugin({
+            name: data.name,
+            library: {
+              type: 'var',
+              name: ['_JUPYTERLAB', data.name]
+            },
+            filename: 'remoteEntry.[contenthash].js',
+            exposes,
+            shared
+          }),
+          new CleanupPlugin()
+        ]
       },
-      plugins: [
-        new ModuleFederationPlugin({
-          name: data.name,
-          library: {
-            type: 'var',
-            name: ['_JUPYTERLAB', data.name]
-          },
-          filename: 'remoteEntry.[contenthash].js',
-          exposes,
-          shared
-        }),
-        new CleanupPlugin()
-      ]
-    })
+      customWebpackConfig
+    )
   ].concat(extras);
 
   if (mode === 'development') {