Skip to content

feat: support customProps.cssUrls#19

Open
TatsuyaYamamoto wants to merge 5 commits intosingle-spa:mainfrom
TatsuyaYamamoto:app-props-css-urls
Open

feat: support customProps.cssUrls#19
TatsuyaYamamoto wants to merge 5 commits intosingle-spa:mainfrom
TatsuyaYamamoto:app-props-css-urls

Conversation

@TatsuyaYamamoto
Copy link
Copy Markdown

@TatsuyaYamamoto TatsuyaYamamoto commented Nov 2, 2022

Sorry for creating PR without asking in issues.

Motivation

I want my single-spa application be able to load css provided from root-config.

An application’s bundled css filename sometimes includes hash (index.abcdef.css). Hash text is detemined in build-time, so bundled js file cannot know hashed css file url. In case single-spa(-css), css urls received in opts.cssUrls cannot has build-time hash.

Example

// single-spa root-config
registerApplication({
  name: 'app1',
  activeWhen: '/app1',
  app: () => import('https://example.com/main.build-time-hash.js'),
  customProps: {
    cssUrls: [
      'https://example.com/main.build-time-hash.css', 👈
      'https://example.com/string-determined-after-build-time/main.css' 👈
    ] 
  }
});
// single-spa application
const cssLifecycles = singleSpaCss({
  cssUrls: [],
});

@filoxo
Copy link
Copy Markdown

filoxo commented Nov 2, 2022

Is this not already supported through the ExposeRuntimeCssAssetsPlugin as noted in the documentation here?

@TatsuyaYamamoto
Copy link
Copy Markdown
Author

My understanding is that ExposeRuntimeCssAssetsPlugin is for webpack only.

In my case, I want to build single-spa application with Vite, so maybe I should create PR to provide vite-plugin. However, I think it would be better to support as a feature that is not dependent on a specific build tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants