【发布时间】:2019-12-07 07:18:01
【问题描述】:
我将几年前做的一个 react-redux 测试项目更新为所有最新版本的 npm 依赖项,但现在我无法编译它。当我运行npm run dev 时出现错误:
ERROR in ./js/client.js 10:16
Module parse failed: Unexpected token (10:16)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const app = document.getElementById('app')
|
> ReactDOM.render(<Provider store={store}>
| <Layout />
| </Provider>, app);
ℹ 「wdm」: Failed to compile.
我的webpack.config.js 看起来像
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, "src"),
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/client.js",
module: {
},
output: {
path: __dirname + "/src/",
filename: "client.min.js"
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
devServer: {
host: "0.0.0.0",
}
};
我知道这在几年前是可行的,但我也知道 JavaScript 世界发展很快。我用谷歌搜索了这条消息,但我发现的所有点击都与 .jsx 文件扩展名有关,而我没有这些。
【问题讨论】:
标签: reactjs npm webpack react-redux