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

Webpack resolver: Support webpack.config.babel.js filename #194

Closed
kentcdodds opened this issue Feb 26, 2016 · 5 comments
Closed

Webpack resolver: Support webpack.config.babel.js filename #194

kentcdodds opened this issue Feb 26, 2016 · 5 comments

Comments

@kentcdodds
Copy link
Contributor

If you rename your file to webpack.config.babel then webpack will transpile it with babel on the fly.

However doing this makes the webpack resolver fail to load the webpack config.

Right now, my workaround is:

// webpack.config.js
/*
 * This file is here until this gets supported:
 */
require('babel-register')
module.exports = require('./webpack.config.babel').default

Would love this to be supported in core. But looking at the code I wasn't certain how you'd want it implemented. I was thinking of extracting this into a function. But feedback is appreciated.

Thanks!

@benmosher
Copy link
Member

Makes sense. That is cool, didn't realize that was possible.

Reminds me of #182. I'd like to avoid slowly rewriting Webpack. This seems like a simple enough thing to fix without biting off integration with enhanced-resolve, though.

Does #164 seem like a workable solution? I didn't really understand what it was doing until reading the SO post you linked.

@kentcdodds
Copy link
Contributor Author

Looks like #164 is using interpret, but not to load the config file (which is what concerns this issue). I've never used interpret myself.

@benmosher
Copy link
Member

Hmm, I read it as "if the config file has an extension that interpret understands, register the compiler for all files with that extension". Which makes sense, no knowing what other non-JS files the config might require.

I've not used it either, but I can imagine it working in such a way.

I'll try it out, and see if I can add some tests.

Or if you've got a different idea you want to try, I'm up for that. Sounds like interpret is a good place to start, though.

@benmosher benmosher added this to the webpack-minor milestone Feb 29, 2016
@gausie
Copy link

gausie commented Feb 29, 2016

interpret is what webpack uses to do it!

@benmosher
Copy link
Member

benmosher commented Apr 29, 2016

I believe this was fixed by #164/#268.

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

No branches or pull requests

3 participants