Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UMD bundle for Kedro-Viz #2256

Closed
wants to merge 13 commits into from
Next Next commit
initial bundle draft
Signed-off-by: ravi_kumar_pilla <ravi_kumar_pilla@mckinsey.com>
  • Loading branch information
ravi-kumar-pilla committed Jan 29, 2025
commit 563182f46457514d0beedb50bac1ad400f048f01
5 changes: 5 additions & 0 deletions src/utils/viz-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import KedroViz from '../components/app/index';

export { React, createRoot, KedroViz };
40 changes: 40 additions & 0 deletions webpack.lib.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');

// Bundle and inline web-workers
module.exports = [
@@ -58,4 +59,43 @@ module.exports = [
],
},
},
{
mode: 'production',
entry: {
KedroViz: './src/utils/viz-entry.js', // Entry point for KedroViz
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.min.js',
library: 'KedroVizBundle', // Name of the UMD library
libraryTarget: 'umd', // UMD allows compatibility across environments
globalObject: 'this', // Ensures compatibility for both browsers and Node.js
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
{
test: /\.scss$/,
use: [
'style-loader', // Injects styles into the DOM
'css-loader', // Translates CSS into CommonJS
'sass-loader', // Compiles SCSS to CSS
],
},
],
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
}
}
];