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

fix css import with webpack #25

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

fix css import with webpack #25

wants to merge 4 commits into from

Conversation

calunia
Copy link

@calunia calunia commented Aug 30, 2023

Hello,
Actually, when i try to import the css with webpack encore, i got the error :
Module not found: Error: Package path ./css/datepicker.css is not exported from package node_modules/stimulus-datepicker (see exports field in node_modules/stimulus-datepicker/package.json)

Change
"exports": "./src/datepicker.js",

to

"files": [
    "css/",
    "src/"
  ],

Fix this issue for me but i don't know how i can run your tests :/
So i open this pr if it can help someone :)
Thx Calunia

@airblade
Copy link
Owner

Thanks for this.

I really have no idea what I'm doing with package.json! There's plenty of documentation online but somehow it never quite explains anything.

I'll try this on my own app (which use import-maps) to check it keeps working.

@Zajn
Copy link

Zajn commented Nov 14, 2024

@airblade Any chance you've had time to try this out with import-maps? I've also run into this issue, and would love to be able to just import the CSS. I'm also not super familiar with how package.json should be structured, so I don't know what migrating from exports to files affects.

Other libraries we use seem to use the files declaration in their package.json (trix comes to mind).

@airblade
Copy link
Owner

@Zajn I haven't tried it out yet.

Thanks for the link to trix's package.json. I see they also have "style": "dist/trix.css" – I wonder what that affects?

Given that import maps are a Javascript feature rather than CSS, how do you plan to use/reference the datepicker's CSS?

@Zajn
Copy link

Zajn commented Nov 19, 2024

Given that import maps are a Javascript feature rather than CSS, how do you plan to use/reference the datepicker's CSS?

The project I'm working on isn't using import maps. We're using jsbundling-rails, and use css-loader to allow us load CSS.

I was asking about import maps since it sounded like you used them and were waiting to see how this PR would affect projects that use it!

@airblade
Copy link
Owner

airblade commented Nov 19, 2024

Oh, I see. I do use import maps but I don't use any kind of CSS bundling; I copy-paste the CSS from any client-side packages I install (usually only this one) into my Rails app. Which is a bit hacky but better than the complexity of CSS bundling.

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.

3 participants