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

CSS dependency with private module @import fails with #1290

Closed
rogy opened this issue Dec 18, 2016 · 3 comments
Closed

CSS dependency with private module @import fails with #1290

rogy opened this issue Dec 18, 2016 · 3 comments

Comments

@rogy
Copy link

rogy commented Dec 18, 2016

Can you reproduce the problem with latest npm?

Yes

Description

CSS dependency with private module @import fails with error

Error in ./~/@privaterepo/somepackage/lib/PropertyPicker/PropertyPicker.css
Module not found: ./@privaterepo/somepackage-two/css/variables/dimension in /Users/rogan/projects/create-react-app-folder/node_modules/@priaterepo/somepackage/lib/PropertyPicker

it produces a lot of these errors for many of the files in @privaterepo/somepackage

an example of how these files look is:

@import '@privaterepo/somepackage-two/css/variables/color';
@import '@privaterepo/somepackage-two/css/variables/dimension';
@import './DateInput.css';

.somecss {
  border: solid 1px var(--color-pumiceGray--darker);
}

Expected behavior

It should build

Actual behavior

Fails to build with the above error

Environment

Run these commands in the project folder and fill in their results:

  1. node -v: 6.9.0
  2. npm -v: 4.0.5

Then, specify:

  1. Operating system: MacOS Sierra
  2. Browser and version: Chrome 55
@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Tagging because we need to report this upstream to Webpack (if the issue is still reproducing).
Feel free to untag after we have reported it.

@gaearon gaearon modified the milestones: 0.9.2, 0.9.1, 0.9.4, 0.9.3 Feb 24, 2017
@gaearon
Copy link
Contributor

gaearon commented Mar 5, 2017

This is not a bug with scoped packages.
The same happens if you import from any npm package:

@import 'my-package/something.css';

The reason is because Webpack doesn’t know this CSS file “understands” module system, and so it assumes that my-package/something.css is relative, for backwards compatibility with normal CSS.

The workaround is simple: put ~ before the package name to tell Webpack it’s a Node module:

@import '~my-package/something.css';

This works with scoped packages too:

@import '~@my-user/my-package/something.css';

I hope this helps!

@gaearon gaearon closed this as completed Mar 5, 2017
@gaearon gaearon removed the issue: bug label Mar 5, 2017
@gaearon gaearon removed this from the 0.9.4 milestone Mar 5, 2017
@TaguranJohnFranz
Copy link

how can i deploy my react app to heroku with private modules?

@lock lock bot locked and limited conversation to collaborators Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants