-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel throws on JSX files when preset-react is not added. #900
Comments
You need to add
|
@JLHwung var DIST_DIR = path.resolve(__dirname, "dist"); module.exports = { |
I would think you should have a different error? https://github.com/babel/babel-loader#install the packages you are installing are not the same name (the babel config and install should match): You'd need to install
|
"babel-loader": "^8.1.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^4.44.2",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.1"
const path = require("path");
var SRC_DIR = path.resolve(__dirname, "src");
///////////////////////////file web webpack.config /////////////////////////////
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
},
resolve: {
extensions: [".js", ".jsx"],
alias: {
assets: path.resolve(__dirname, "src/assets/"),
},
},
module: {
rules: [
{
test: /.jsx?$/,
loader: "babel-loader",
include: __dirname + "/src/",
exclude: /node_modules/,
query: {
presets: ["babel-preset-myPreset", "@babel/preset-env"],
},
},
],
},
// resolve: {
// extensions: ["*", ".js", ".jsx"],
// alias: {
// assets: path.resolve(__dirname, "/src/Main/assets"),
// },
// },
};
ERROR in ./src/index.js 7:2
Module parse failed: Unexpected token (7:2)
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
|
| ReactDOM.render(
file index
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
ReactDOM.render(
<React.StrictMode>
</React.StrictMode>,
document.getElementById('root')
);
The text was updated successfully, but these errors were encountered: