Using ES6 import and export default inside webpack.config

Viewed 1642

I would like to be able to use es6 imports and export default inside my webpack.config. If I run my webpack like this.

webpack.config.js

"webpack": "cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js"

I get an error SyntaxError: Unexpected token import whick is expected. Then I found on other questions solution that seemed to work for a lot of people. Renaming file to webpack.config.babel.js and including babel-register. I tried that webpack.config.babel.js

"webpack": "cross-env NODE_ENV=development node -r babel-register node_modules/.bin/webpack-dev-server --config=webpack.config.babel.js"

but now I get this error

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list

I tried a lot more combinations with babel-node and babel-register but nothing seems to work. I am on windows 10. How do I do this?

1 Answers
Related