Setting Webpack Env Breaks Babel-Loader: "Need an appropriate loader"
I'm submitting a bug report
Webpack Version: 2.2.1
Babel Core Version: 6.24.0
Babel Loader Version: 6.2.10 / 6.4.x / 7.0.0-beta.1
Please tell us about your environment: OSX Current
Current behavior:
Babel-loader works fine with vanilla webpack.config. Switching webpack config files using a --env=dev or --env=prod flag throws error: You may need an appropriate loader to handle this file type. Appears babel presets and plugins not loading correctly?
- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
https://gist.github.com/jtulk/7cf5ffd95714f7548e4ba7ec10327cb0
If I read the webpack docs correctly it should be
webpack --env.prod
and not
webpack --env=prod
https://webpack.js.org/configuration/configuration-types/
@danez - Sorry I missed your response.
This isn't the issue. The . just passes in an object instead of a string value as documented here in the docs. I've tried it both ways, succeeded both ways, but my issue still remains:
ERROR in ./src/app/index.js
Module parse failed: /Users/justin/Sites/myRepo/src/app/index.js Unexpected token (89:2)
You may need an appropriate loader to handle this file type.
|
| const router = (
| <Provider store={store}>
| <Router
| history={hashHistory}
@ multi (webpack)-dev-server/client?http://localhost:9000 babel-polyfill ./src/app/index.js
My module config is:
module: {
rules: [
{
test: /\.jsx?$/,
include: [path.resolve(__dirname, "src")],
exclude: [
path.resolve(__dirname, "src/js"),
path.resolve(__dirname, "node_modules")
],
loader: "babel-loader",
options: {
presets: ["es2015", "react", "stage-0"],
plugins: [
"transform-async-functions",
"transform-object-rest-spread",
"transform-regenerator"
]
}
}
]
},
Wait - hold on. All my path.resolve(__dirname, "") calls in webpack.config are now wrong because I moved it into a /config folder. Switching them to path.join(__dirname, "/../*" fixed my issues. Sorry world.