There is a problem when jsx introduces a public js file in react.

1.weboack.config.js

{
    test: /\.js$/,
    exclude: /node_modules/,
    loader: "babel-loader",
    query: {
        presets: ["es2015", "babel"]
    }
},

2.common.js

var font={
    remFont:function(){
        alert(1)
    }
}
export default font

3.jsx

import font from "../common.js"

I wanted to introduce a public js file into the jsx file, but now the page error is

clipboard.png

what I found was that the babel in webpack.config was changed to babel-loader, but my webpack.config was babel-loader from the beginning. May I ask what caused this?

Mar.21,2021

configure parsing using babel core

Menu