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

Configure lookup paths for composes/from #13

Closed
dfreeman opened this issue Dec 15, 2015 · 12 comments
Closed

Configure lookup paths for composes/from #13

dfreeman opened this issue Dec 15, 2015 · 12 comments
Assignees

Comments

@dfreeman
Copy link
Contributor

I'm still wrapping my head around the standard patterns for how PostCSS plugins consume configuration, but it doesn't look like there's currently a way to pass configuration through to postcss-import to configure the root and search path(s) for composes foo from 'bar' lookups.

Is this something that it would make sense to add, or am I missing something fundamental? I'm also happy to put together a PR if you have a form factor in mind for how you might want to consume such configuration.

@madyankin
Copy link
Owner

Hi, thank you for the feedback. You have to use paths relative to the root path right now, but I'm going to fix that soon.

@madyankin
Copy link
Owner

@hellosmithy, @dfreeman Fixed, the new version is published

@ghost
Copy link

ghost commented Mar 10, 2016

I am having s similar issue on version 0.4.0 (latest today on npm):

{ [Error: ENOENT: no such file or directory, open '/Users/tarikansari/Workspace/sane-web/src/components/GenrePicker/theme/elements/button-dark']
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/tarikansari/Workspace/sane-web/src/components/GenrePicker/theme/elements/button-dark' }

It is looking for the file next to the path of the file that includes the composes, instead of using the path option configured on postcss-import. I don't have this issue when using webpack/css-loader?modules as it used the resolves/root option of webpack to look into the correct paths for files.

How are we supposed to pass the include path to postcss-modules?

@madyankin
Copy link
Owner

@tarikihm thank you for the feedback! Could you make a minimal reproduceable example, please?

@ghost
Copy link

ghost commented Mar 10, 2016

May not have time to write one until a couple days, for now here is more information: this is related to css-modules-loader-core which uses require.resolve() to resolve import

The way other tools handle this: css-loader instead uses the context of Webpack, and postcss-import accept a path option, which is probably the approach postcss-modules should take.

A quick hacky workaround for me was to add a symlink named theme pointing to src/theme into node_modules, however that is not all, postcss-modules then fails to resolves composes which omit the .css extension, which are properly resolved by both postcss-import and css-loader.

@ghost
Copy link

ghost commented Mar 10, 2016

Should this issue be re-opened?

@madyankin madyankin reopened this Mar 10, 2016
@madyankin
Copy link
Owner

@tarikihm I will make an option to set the root directory in a couple of days. For now you can use relative paths for composes.

@madyankin madyankin self-assigned this Mar 10, 2016
@ghost
Copy link

ghost commented Mar 10, 2016

Thank you @Outpunk, you may also want to follow postcss/postcss#240 where adding a path option to PostCSS is being discussed. This would allows you to make the new option invisible once PostCSS introduces this.

@bernardodiasc
Copy link

I see this is an old issue, but since still open. This plugin solved this problem for me https://www.npmjs.com/package/postcss-modules-resolve-path

@FezVrasta
Copy link

Is this issue under the radar?

@kamilic
Copy link
Contributor

kamilic commented Jul 18, 2021

Need this feature.

kamilic pushed a commit to kamilic/postcss-modules that referenced this issue Jul 20, 2021
kamilic pushed a commit to kamilic/postcss-modules that referenced this issue Jul 20, 2021
madyankin pushed a commit that referenced this issue Jul 21, 2021
* feat(#13): add custom lookup path option

* feat: add typing of opt.resolve

Co-authored-by: kamilic <kamilic.work@outlook.com>
@madyankin
Copy link
Owner

Added in #126

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

No branches or pull requests

5 participants