响应文件的 Webpack 编译错误。编译器似乎在每个反应文件上抛出错误,如下所示:
ERROR in ./public/react-components/modules/user/profile/edit.js
Module parse failed: /Workspace/bungaloow/public/react-components/modules/user/profile/edit.js Unexpected token (5:26)
You may need an appropriate loader to handle this file type.
网络包配置:
var glob = require('glob');
module.exports = {
entry: glob.sync('./public/react-components/**/*.{js,json}'),
output: {
path: __dirname + '/public/compiled',
filename: "react-components.js"
},
module: {
loaders: [
{test: /\.js$/, loader: 'babel-loader', query: {presets: ['es2015','react']}}
],
rules: [
{
test: /\.json$/,
use: 'json-loader'
},
{
test: /\.js$/,
use: 'babel-loader'
}
]
},
watch: true
};