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

Incompatible CSS module usage in Vite 5 #150

Open
1 task done
sangquangnguyen opened this issue Mar 13, 2024 · 0 comments
Open
1 task done

Incompatible CSS module usage in Vite 5 #150

sangquangnguyen opened this issue Mar 13, 2024 · 0 comments

Comments

@sangquangnguyen
Copy link

sangquangnguyen commented Mar 13, 2024

Report a bug:

  • Encounter error: node_modules/flag-icon-css/css/flag-icon.css does not provide an export named 'default' when using Vite 5 because of incompatible CSS module usage.
Screenshot 2024-03-13 at 21 30 11

Basic information:

  • react-flag-icon-css version: 1.0.25

  • Module bundler: Vite (rollup) version: 5.0.12

  • The output of node -v: 18.17.0

  • I am using standard Css.

Description

  • I'm using Vite that supports CSS Modules. However Vite deprecated the CSS default export (ref) in the version 5. So I encountered the issue when using our library because Vite does NOT exporting named default if we are missing ?inline query

Ref: https://vitejs.dev/guide/features.html#disabling-css-injection-into-the-page
Screenshot 2024-03-13 at 21 36 26

How I am creating FlagIcon

import FlagIconFactory from 'react-flag-icon-css';

const FlagIcon = FlagIconFactory(React, { useCssModules: false });

Expected behavior or result

  • Loaded CSS correctly when using this lib

Actual behavior or result

  • Encounter error
Screenshot 2024-03-13 at 21 30 11

Propose a feature:

  • Release 1 version with the correct approach when using Vite
import stylesFlagIcon from 'flag-icon-css/css/flag-icon.css?inline'
import stylesMain from './styles/main.css?inline'
// Inject CSS  if needed
import 'flag-icon-css/css/flag-icon.css';
import './styles/main.css';
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

No branches or pull requests

1 participant