This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sandbox): Build sandbox application with webpack
At this moment, vite's module federation plugin seems incompatible with webpack's counterpart, causing the steps extensions not to load. This commit adds a webpack config to build the sandbox application without removing vite. The reasoning is that vite offers a much faster experience and it's likely that the steps extensions won't be loaded as module federation but rather by being part of the final build. fixes: #2216 relates: #1759
- Loading branch information
Showing
4 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Kaoto</title> | ||
<meta id="appName" name="application-name" content="Kaoto"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
|
||
<body> | ||
<noscript>Enabling JavaScript is required to run this app.</noscript> | ||
<!-- root element for the React Host application --> | ||
<div id="root"></div> | ||
|
||
<!-- root element for the Envelope applications --> | ||
<div id="envelope-app"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
const webpack = require('webpack'); | ||
const path = require('path'); | ||
const { merge } = require('webpack-merge'); | ||
const webpackCommonConfig = require('../kaoto-ui/webpack.dev'); | ||
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const { federatedModuleName } = require('../kaoto-ui/package.json'); | ||
|
||
webpackCommonConfig.plugins = webpackCommonConfig.plugins.filter((plugin) => { | ||
return ( | ||
!(plugin instanceof HtmlWebpackPlugin) && | ||
!(plugin instanceof webpack.container.ModuleFederationPlugin) | ||
); | ||
}); | ||
webpackCommonConfig.module = undefined; | ||
webpackCommonConfig.resolve = undefined; | ||
|
||
module.exports = merge(webpackCommonConfig, { | ||
entry: { | ||
index: path.resolve(__dirname, './src/main.tsx'), | ||
'kaoto-editor': path.resolve(__dirname, './src/envelope/KaotoEditorEnvelopeApp.ts'), | ||
'serverless-workflow-text-editor': path.resolve( | ||
__dirname, | ||
'./src/envelope/ServerlessWorkflowTextEditorEnvelopeApp.ts', | ||
), | ||
}, | ||
output: { | ||
path: path.resolve('./dist'), | ||
hashDigestLength: 8, | ||
filename: 'assets/[id]-[chunkhash].js', | ||
assetModuleFilename: 'assets/[name]-[hash][ext]', | ||
clean: true, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
enforce: 'pre', | ||
use: ['source-map-loader'], | ||
}, | ||
{ | ||
test: /\.m?js/, // related to: https://github.com/webpack/webpack/discussions/16709 | ||
resolve: { | ||
fullySpecified: false, | ||
}, | ||
}, | ||
{ | ||
test: /\.(tsx|ts|jsx)?$/, | ||
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
options: { | ||
transpileOnly: true, | ||
experimentalWatchApi: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.(sa|sc|c)ss$/i, | ||
use: ['style-loader', 'css-loader'], | ||
}, | ||
{ | ||
test: /\.(ttf|eot|woff|woff2)$/, | ||
type: 'asset/resource', | ||
}, | ||
{ | ||
test: /\.(svg|jpg|jpeg|png|gif)$/i, | ||
type: 'asset/inline', | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
favicon: path.resolve(__dirname, 'src/assets', 'favicon.svg'), | ||
chunks: ['index'], | ||
template: path.resolve(__dirname, 'webpack-template-index.html'), | ||
filename: 'index.html', | ||
}), | ||
new HtmlWebpackPlugin({ | ||
favicon: path.resolve(__dirname, 'src/assets', 'favicon.svg'), | ||
chunks: ['kaoto-editor'], | ||
template: path.resolve(__dirname, 'webpack-template-index.html'), | ||
filename: 'envelope-kaoto-editor.html', | ||
}), | ||
new HtmlWebpackPlugin({ | ||
favicon: path.resolve(__dirname, 'src/assets', 'favicon.svg'), | ||
chunks: ['serverless-workflow-text-editor'], | ||
template: path.resolve(__dirname, 'webpack-template-index.html'), | ||
filename: 'envelope-serverless-workflow-text-editor.html', | ||
}), | ||
new webpack.container.ModuleFederationPlugin({ | ||
name: federatedModuleName, | ||
filename: 'remoteEntry.js', | ||
library: { type: 'var', name: federatedModuleName }, | ||
shared: { | ||
react: { | ||
eager: true, | ||
}, | ||
'react-dom': { | ||
eager: true, | ||
}, | ||
}, | ||
}), | ||
], | ||
ignoreWarnings: [/Failed to parse source map/], | ||
resolve: { | ||
fallback: { | ||
path: require.resolve('path-browserify'), | ||
}, | ||
extensions: ['.js', '.ts', '.tsx', '.jsx'], | ||
modules: ['node_modules'], | ||
plugins: [ | ||
new TsconfigPathsPlugin({ | ||
configFile: path.resolve(__dirname, './tsconfig.json'), | ||
}), | ||
], | ||
symlinks: false, | ||
cacheWithContext: false, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters