trayio / babel-plugin-webpack-alias

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

Does not seem to work with babel #46

Open tituswoo opened 7 years ago

tituswoo commented 7 years ago

Love this plugin. However I seem to be having some issues with the plugin/preset run ordering... Given the following .babelrc file:

{
  "presets": ["react", "es2015", "stage-0"],
  "plugins": [
    [ "webpack-alias", { "config": "${PWD}/webpack.config.babel.js" } ]
  ],
  "ignore": [
    "dist/*"
  ]
}

I get the following error when running babel src -d dist in my terminal:

Unexpected token import

What's weird though is if I remove the webpack-alias plugin, everything compiles correctly. Interestingly, if I use webpack-alias with node-babel, it also works. Only when I use babel from the babel-cli package do I get the error.

Zaktus commented 7 years ago

Same problem, can not run SSR :(

feifanzhou commented 6 years ago

Workaround: Use babel-plugin-module-resolver (which appears to be maintained). You'll have to duplicate the config, but it actually works