Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/plugin-icestark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const PLUGIN_NAME = '@ice/plugin-icestark';
const plugin: Plugin<PluginOptions> = ({ type, library }) => ({
name: PLUGIN_NAME,
setup: ({ onGetConfig, context, generator, modifyUserConfig }) => {
const libraryName = library || context.pkg?.name as string || 'microApp';
const libraryName = library || (context.pkg?.name as string) || 'microApp';
onGetConfig((config) => {
config.configureWebpack ??= [];
config.configureWebpack.push((webpackConfig) => {
Expand Down Expand Up @@ -52,12 +52,13 @@ export async function mount(props) {
// Props of container if conflict with render node in ice, it may cause node overwritten.
let runtimeOptions = props;
if (props.singleSpa) {
const iceContainer = props.container?.querySelector('#ice-container');
const targetId = app?.default?.app?.rootId || 'ice-container'
const iceContainer = props.container?.querySelector('#' + targetId);
if (iceContainer) {
runtimeOptions = {...props, container: iceContainer };
} else {
const ele = document.createElement('div');
ele.id = 'ice-container';
ele.id = targetId;
props.container.appendChild(ele);
runtimeOptions = {...props, container: ele };
}
Expand All @@ -72,7 +73,7 @@ export async function unmount(props) {
// Reset root to null when app unmount.
root = null;
}`;
});
});
} else {
// Plugin icestark do not support ssr yet.
modifyUserConfig('ssr', false);
Expand Down