Send file path to browserslist #26

Open
ai opened this Issue Oct 13, 2016 · 5 comments

Projects

None yet

4 participants

@ai
ai commented Oct 13, 2016

Browserslist could use browserslist config file. It is useful, because many different tools will share same config (Autoprefixer, Stylelint, cssnext, doiuse).

But to enable a config, you need to pass a path for current file:

browserslist(opts.browsers, { path: opts.file })
@hzoo
Member
hzoo commented Oct 13, 2016

I guess we could check the file but given a preset could be somewhere else I'm not sure.

Also relevant facebookincubator/create-react-app#892

@hzoo
Member
hzoo commented Nov 10, 2016

If someone wants to make a PR

@Kovensky
Contributor
Kovensky commented Nov 10, 2016 edited

I tried looking into it, but the preset doesn't have access to useful information about the .babelrc or the file being processed 😕

The preset is called with a context argument, but it turns out that the context is actually just the node api namespace, which you can easily import yourself, instead of an actual context, so there's not even any way to know which .babelrc is being used, let alone which file is being transformed 😢

@p-jackson

I made a PR, but having slept on it I feel like the original suggestion would be much more elegant.

Looks like it'd be possible to change babel-core to pass the current file to the preset. Do you think babel-core would be open to a PR like that?

@ai
ai commented Jan 4, 2017

@hzoo I changed Browserslist to fit Babel and CRA requirements. Not it is your turn to enable a config (not just a option).

@jaydenseric jaydenseric referenced this issue in jaydenseric/Barebones Jan 15, 2017
Closed

Reconfigure Babel to use babel-preset-env #18

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