stealjs / steal-less

A less plugin for StealJS
https://www.npmjs.com/package/steal-less
MIT License
4 stars 2 forks source link

private npm package with absolute path goes to wrong location #54

Closed PieterSwitten closed 7 years ago

PieterSwitten commented 7 years ago

I have a private npm package installed in my project where I have an absolute path to some image outside of my private package. There is an error thrown that it cannot find the image with the path '..../node_modules/@scope/images/svg/...' It looks like it cannot go outside my scope.

After I build the application the image links to the correct location.

matthewp commented 7 years ago

What does the path look like in the import?

PieterSwitten commented 7 years ago

background-image: url('/images/svg/myimage.svg')

matthewp commented 7 years ago

Oh, I see, and you expect this to load from your server root, right?

PieterSwitten commented 7 years ago

Yes indeed

matthewp commented 7 years ago

Thanks, will try and get this fixed soon.

matthewp commented 7 years ago

Hey @PieterSwitten I tried recreating, but I think my code is a bit different from yours.

Looking below, I have an npm dependency that is being required, and it's url() contains an absolute url. However this loads fine. How is this example different from your code?

screen shot 2017-08-22 at 12 47 26 pm

PieterSwitten commented 7 years ago

First I also installed my component as a 'normal' package and then it worked. The problem was when I published it to a private npm package with a scope and then installed it.

The package is like this in the package.json:

"dependencies": {
    "@my-scope/my-package": "^1.0.1",
    "steal-less": "^1.1.0",
    ....
}

In the /node_modules the structure is like

node_modules
  |– ...
  |– @my-scope
          |– my-package
  |– ...
  |– steal-less

It looks like steal-less is seeing the @my-scope as the root. With other packages earlier I had indeed no problem

matthewp commented 7 years ago

Ok, how are you importing the less file that is in @my-scope/my-package?

PieterSwitten commented 7 years ago

The first less file is imported from the javascript like

import './my-component.less';

Within my-component.less I import an image.less file which handles the paths to the images. In the less file it's imported like this

import '../styles/image/image.less';
matthewp commented 7 years ago

Yeah, but how is @my-scope/my-package/styles.less imported?

matthewp commented 7 years ago

Ok, when I stuck my dependency in node_modules/@priv/dep now I see the problem (I think). Going to see what is going on.

matthewp commented 7 years ago

The underlying bug is in https://github.com/stealjs/steal/issues/1253, will track the fix there.