trayio / babel-plugin-webpack-alias

babel 6 plugin which allows to use webpack resolve options
MIT License
150 stars 32 forks source link

Webpack config not found when using es6 export statement #12

Closed giannif closed 8 years ago

giannif commented 8 years ago

In webpack.config.babel.js

If I use:

export default {
 // webpack config properties
}

babel-plugin-webpack-alias's getConfig fails because it needs to reference default (as of Babel 6)

Perhaps checking the __esModule could help determine if we should use default

function getConfig(configPath, findConfig) {
    var conf;
    if(!findConfig) {
        // Get webpack config
        conf = require(resolve(process.cwd(), configPath));
    } else {
        conf = require(findUp.sync(configPath));
    }
    if (conf && conf.__esModule) {
        conf = conf.default
    }
    return conf;
}
sebinsua commented 8 years ago

For those reading these issues, wondering how they can use the fixes that haven't yet been merged, I have a fork of this plugin that works for me:

babel-plugin-webpack-aliases

giannif commented 8 years ago

@sebinsua this is awesome! Maybe you could mention the new name :) I didn't realize it right away

adriantoine commented 8 years ago

@sebinsua would you mind making a PR to this repo?

adriantoine commented 8 years ago

A fix has been made and it is included in v1.7.0!