React - Module parse failed
You need add babel-loader
, with react preset
, do the following steps
npm i --save-dev babel-loader babel-preset-react babel-preset-es2015
add to
webpack.config.js
configs forbabel-loader
( toloaders: [..]
section){ test: /\.jsx?$/, exclude: /(node_modules)/, loader: 'babel', query: { presets: ['react', 'es2015'] } }
Update: babel-preset-es2015
, babel-preset-react
was deprecated in favor of using @babel/env
and @babel/preset-react
npm i --save-dev babel-loader @babel/core @babel/preset-react @babel/preset-env
- add to
webpack.config.js
configs forbabel-loader
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}
}
]