Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

loadPaths should be able to handle glob #40

Closed
aegyed91 opened this issue Jan 15, 2016 · 10 comments
Closed

loadPaths should be able to handle glob #40

aegyed91 opened this issue Jan 15, 2016 · 10 comments

Comments

@aegyed91
Copy link

Hi @borodean, I think the loadPaths option does not handle glob patterns. It would be an useful feature i think.

assets({
  basePath: config.SRC_DIR,
  loadPaths: [path.join(config.DEST_DIR, '**/*')],
  relativeTo: 'public/css'
})
[21:54:48] Starting 'css'...

events.js:141
      throw er; // Unhandled 'error' event
      ^
Error: postcss-assets: /Users/tsm/Sites/__projects/gulp-starter/src/css/main.css:2:3: Asset not found or unreadable: sample.jpeg
Load paths:
  /Users/tsm/Sites/__projects/gulp-starter/src
  /Users/tsm/Sites/__projects/gulp-starter/public/**/*
.sample-bg-image {
  background-image: resolve("sample.jpeg"); }
@borodean
Copy link
Owner

@tsm91 whats the use case of this?

@aegyed91
Copy link
Author

@borodean if you have an asset-pipeline which is project-structure agnostic like this.

In my case it doesn't cause any problems because the images gulp task will copy the image from anywhere to public/images but only because i use gulp-flatten and because of the file watcher.

But i am sure there will be scenarios for other people when they would like to do something like src/**/* or dist/**/*.

@dan-gamble
Copy link

I've just hit this myself as well, since we break things out into small modules we don't have a single root of assets anymore.

Being able to use: name/apps/*/img/ would be sweet :)

@borodean
Copy link
Owner

@tsm91 @dan-gamble here you go: introduced in 4.0.0.

@dan-gamble
Copy link

Awesome <3

@aegyed91
Copy link
Author

cool, thanks

@borodean
Copy link
Owner

borodean commented Feb 1, 2016

@tsm91 @dan-gamble btw, the plugin now accepts a single string as a loadPaths option, so instead of this:

loadPaths: ['assets/**/img']

You can also write this:

loadPaths: 'assets/**/img'

@dan-gamble
Copy link

Thanks for the heads up :)

@anotherWill
Copy link

Hi @borodean, how to write the options about this url.
appName/src/assets/images/test.png
and css in appName/src/assets/css/main.css
resolve('test.png')
I try it a long time and throw error. Assets not found or unreadable

@borodean
Copy link
Owner

@anotherWill well, I assume something like this should work:

loadPaths: 'appName/src/assets/images'

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

4 participants