gpt4 book ai didi

javascript - Webpack JSX 错误 : You may need an appropriate loader to handle this file type

转载 作者:行者123 更新时间:2023-11-27 23:19:11 24 4
gpt4 key购买 nike

我正在尝试使用 webpack 构建项目,但出现错误。我之前能够使用 gulp 构建这个项目,所以所有路径和一切都应该没问题。我安装了本文档 https://github.com/babel/babel-loader 中的所有 babel 加载器并复制示例中的代码。

ERROR in ./src/app.jsx
Module parse failed: ..path../src/app.jsx Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React from 'react';
| import ReactDom from 'react-dom';
@ multi main

我的 webpack.config 文件:

var webpack = require("webpack");
var path = require("path");

module.exports = {
devtools: 'inline-source-map',
entry: [
'./src/app.jsx'
],
output: {
path: '../app/www/js/',
filename: 'bundle.js'
},
resolve: {
modulesDirectories: [path.join(__dirname, 'node_modules')],
extensions: ['', '.js', '.jsx', '.scss']
},
modules: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.scss$/,
exclude: /(node_modules|bower_components)/,
loaders: ["style", "css", "sass"]
}
]
}
};

最佳答案

应该是 loader: 'babel',而不是 loader: 'babel-loader'

编辑:显然它们是等效的。问题出在 Webpack 配置文件中,它是 module,而不是 modules

关于javascript - Webpack JSX 错误 : You may need an appropriate loader to handle this file type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35534699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com