Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Expose path to Draft.css for usage by CSS pre-processors #566

Closed
wants to merge 1 commit into from

Conversation

darobin
Copy link

@darobin darobin commented Jul 27, 2016

Summary

Some CSS pre-processors understand node_modules and are able to @import without requiring an absolute path. However, without assistance from the module all that they can resolve is its root directory. This leads to @import statements like the following:

@import "draft-js/dist/Draft.css";

While this works, it requires internal knowledge of the package's layout. This requires digging around and if the layout changes, this breaks.

These pre-processors also recognise a style field in package.json, which is the equivalent of main for CSS. This allows one to import thusly:

@import "draft-js";

It's a small change, but it helps!

@zpao
Copy link
Contributor

zpao commented Jul 29, 2016

Interesting. What preprocessors work like this? (so we can test on our end and ensure we have some knowledge about what will and won't work)

@darobin
Copy link
Author

darobin commented Jul 29, 2016

Typically anything built on top of https://github.com/postcss/postcss-import (of which there are a few). If you want to test the simplest is probably to just use postcss-import directly.

@hellendag
Copy link

I'm fine with this. @zpao, any concerns?

@flarnie
Copy link
Contributor

flarnie commented Oct 13, 2017

Not sure why CI never finished - I think we could merge this if it's not too late. Adding it to my queue.

@flarnie flarnie self-requested a review October 13, 2017 16:40
@flarnie
Copy link
Contributor

flarnie commented Oct 13, 2017

PS - I might have trouble merging this because it's been open for so long. If @darobin you are able to rebase it onto master and force push, that should re-trigger CI and make it easier to merge.

@darobin
Copy link
Author

darobin commented Oct 13, 2017

Hi — sorry, I no longer use draft-js or for that matter work in development. I don't have anything set up on this machine. It's a one-line change to package.json though so it shouldn't be too hard to bring it back :)

@darobin
Copy link
Author

darobin commented Oct 13, 2017

Actually @flarnie, GitHub says it's mergeable without a hitch so you should be fine there. Just ignore CI (or kick it over in the Travis UI), this really shouldn't break tests.

@flarnie
Copy link
Contributor

flarnie commented Oct 13, 2017

Agreed - the only hitch is that our scripts for pulling changes into the Facebook codebase may try to verify that CI is passing on the branch. If so then I'll make a new branch.

Good luck with whatever you are doing now! :) 🌅

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarnie is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarnie has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@flarnie
Copy link
Contributor

flarnie commented Oct 18, 2017

Internally I'm getting a merge conflict and unable to rebase it - our system expects that rebasing and conflict resolution will happen on Github, and I haven't been able to access this branch to rebase it.

I'll just make a new PR with this change, hope that's ok. Credit goes to @darobin for this change, and sorry again it went so long without review.

@flarnie flarnie closed this Oct 18, 2017
flarnie added a commit to flarnie/draft-js that referenced this pull request Oct 18, 2017
**what is the change?:**
CREDIT TO @darobin for this change, originally made in
facebookarchive#566

---

Some CSS pre-processors understand node_modules and are able to @import without requiring an absolute path. However, without assistance from the module all that they can resolve is its root directory. This leads to @import statements like the following:

```
@import "draft-js/dist/Draft.css";
```

While this works, it requires internal knowledge of the package's layout. This requires digging around and if the layout changes, this breaks.

These pre-processors also recognise a style field in package.json, which is the equivalent of main for CSS. This allows one to import thusly:

```
@import "draft-js";
```

It's a small change, but it helps!
facebook-github-bot pushed a commit that referenced this pull request Oct 18, 2017
Summary:
**what is the change?:**
CREDIT TO darobin for this change, originally made in
#566

 ---

Some CSS pre-processors understand node_modules and are able to import without requiring an absolute path. However, without assistance from the module all that they can resolve is its root directory. This leads to import statements like the following:

```
import "draft-js/dist/Draft.css";
```

While this works, it requires internal knowledge of the package's layout. This requires digging around and if the layout changes, this breaks.

These pre-processors also recognise a style field in package.json, which is the equivalent of main for CSS. This allows one to import thusly:

```
import "draft-js";
```

It's a small change, but it helps!
Closes #1442

Differential Revision: D6088534

fbshipit-source-id: fcede534a18620907adfb6a30391b9f722756e8c
midas19910709 added a commit to midas19910709/draft-js that referenced this pull request Mar 30, 2022
Summary:
**what is the change?:**
CREDIT TO darobin for this change, originally made in
facebookarchive/draft-js#566

 ---

Some CSS pre-processors understand node_modules and are able to import without requiring an absolute path. However, without assistance from the module all that they can resolve is its root directory. This leads to import statements like the following:

```
import "draft-js/dist/Draft.css";
```

While this works, it requires internal knowledge of the package's layout. This requires digging around and if the layout changes, this breaks.

These pre-processors also recognise a style field in package.json, which is the equivalent of main for CSS. This allows one to import thusly:

```
import "draft-js";
```

It's a small change, but it helps!
Closes facebookarchive/draft-js#1442

Differential Revision: D6088534

fbshipit-source-id: fcede534a18620907adfb6a30391b9f722756e8c
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants