segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.33k stars 131 forks source link

Passing options, such as paths, to importer #135

Open jasonmit opened 9 years ago

jasonmit commented 9 years ago

Is it within the scope of the project to permit passing options, such as path to importer?

For example:

// reduced for brevit
// options.paths = ['/home/jasonmit/project', '/home/jasonmit/project/styles/app.css']
exports.import = function(options){
  return importer({
    path: options.paths
  })
};

https://github.com/segmentio/myth/blob/master/lib/features.js#L26

Would permit:

// project/styles/app.css
@import 'bower_components/foo/bar/baz.css';

Right now I need to use relative paths everywhere for imports outside of the source directory to be importable. I thought this was what the paths option was for, but then noticed it never gets passed to the importer.

// project/styles/app.css
@import '../../bower_components/foo/bar/baz.css';
ianstormtaylor commented 9 years ago

Totally! We actually do it for other options already. We'd just need to come up with a name, although path sounds good to me.

Edit: although if it's an array of paths then plural

jasonmit commented 9 years ago

Okay, I'll send a PR tonight tomorrow :+1:

jasonmit commented 9 years ago

@ianstormtaylor PR opened if you can take a look and provide feedback. Thanks :)