現在、webpack 2をbabelで動作させようとしています。babel/webpack2/reactでこのファイルタイプを処理するには、適切なローダーが必要な場合があります。
HERESに私のwebpack.config.js:
'use strict';
module.exports = [
{
entry: './src/client/app/private.jsx',
output: {
path: './',
filename: './src/client/private/bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
rules: [
{
use: [
{
loader: 'babel-loader',
options: {
presets: [
['es2015', { modules: false }],
['es2016', { modules: false }],
'react'
],
}
},
],
exclude: /node_modules/
}
]
}
}
];
.babelrc:
{
"presets": [
"es2015",
"es2016",
"react"
],
"plugins": [
"transform-react-jsx",
"transform-regenerator"
]
}
とエラー:
ERROR in ./src/client/app/private.jsx
Module parse failed: /home/karl/dev/node/project/src/client/app/private.jsx Unexpected token (7:16)
You may need an appropriate loader to handle this file type.
| import Index from './containers/Index/index.jsx';
|
| ReactDOM.render(<Index />, document.getElementById('root'));