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

How can i import a stylus file from nested node_modules? #175

Closed
LancerComet opened this issue Jun 1, 2017 · 2 comments
Closed

How can i import a stylus file from nested node_modules? #175

LancerComet opened this issue Jun 1, 2017 · 2 comments

Comments

@LancerComet
Copy link

Normally we do this in a project (Let's call this project "project-01"):

// In "project-01/my-style.styl":
@import "~some-package/index.styl"
// This file is required from "project-01/node_modules/some-package/index.styl".

When I started a new project (project-02) with both project-01 and some-package installed:

// In "project-02/my-style.styl":
@import "~some-package/index.styl"
// This file is required from "project-02/node_modules/some-package/index.styl".

// In "project-02/node_modules/project-01/my-style.styl"
@import "~some-package/index.styl"
// This file is required from "project-02/node_modules/some-package/index.styl".

So in file project-02/node_modules/project-01/my-style.styl,
I finally get project-02/node_modules/some-package/index.styl (Because of starting with "~"),
but what I want is project-02/node_modules/project-01/node_modules/some-package/index.styl, this is the default behavior of most packages.

So how can I do this? Is there any offical way to change this behavior?
Many thanks :)

@alexander-akait
Copy link
Member

Same problems with

// options
{
  paths: ['node_modules', 'resources/assets/stylus'],
  'include css': true,
  'resolve url': true,
  use: [require('lost'), require('postcss-flexbugs-fixes')]
}
// gallery.styl
@require 'photoswipe/dist/photoswipe.css'
@require 'photoswipe/dist/default-skin/default-skin.css'

.pswp--svg .pswp__button:not(.pswp__button--arrow--left):not(.pswp__button--arrow--right)
.pswp--svg .pswp__button--arrow--left:before,
.pswp--svg .pswp__button--arrow--right:before {
    background-image: url(/assets/app/img/gallery-ui.svg)!important;
  }

@alexander-akait
Copy link
Member

this is the default behavior of most packages.

Sorry, no, but:

  • You need to put project-01 in package.json for project-02
  • project-01 should use stylus/styl property in package.json to export styles (alternative you can use the exports property of package.json, only webpack@5)
  • and import what you need

OR

  • Use the paths prperty

OR

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

2 participants