简体   繁体   中英

React app not rendering after transpiling with webpack (BabelJS) part 2

This post is an extension of my previous post on the same problem. My react code is still not rendering, but I have new information gathered from my troubleshooting efforts:

1) A responder from the last post got my code to work in his environment. To match his environment I downloaded babel-core, babel-loader, and babel-preset-2015. I also changed my version of webpack.config.js:

module.exports = {
    context: __dirname, 
    entry: "./src/App.js",

    output: {
        filename: "app.js",
        path: __dirname + "/assets"
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ["react", "es2015"]
                }
            }
        ]
    }
}

2) The problem is not related to the server because heroku successfully delivers all files.

3) It's not a browser-related issue since the app doesn't render in Chrome, Firefox, and Safari.

All I can think of is that the problem is related to webpack/babel, but do you guys have any other ideas??

From going to the url: https://dry-river-67944.herokuapp.com/

It looks like your js file is not getting sent down. Instead the get request handler for /:input is being used for that request.

app.get("/:input", (req, res) => {
    //Assign headerVal to Access-Control-Allow-Origin response header
    res.set('Access-Control-Allow-Origin', "*")

    //Send response data
    var convertedData = timestampMicroServ(req.params.input)
    res.end(convertedData)
})

Should be put after your staticfile middleware or namespaced ( /api/:input ?):

app.get("/", express.static(path.join(__dirname, '/TMS-Front-End/assets')))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM