Am having a single Git repository where it contains both client and server. This is my Webpack.config.js
const path = require("path");
module.exports = {
devServer: {
contentBase: path.resolve(__dirname, "./src"),
historyApiFallback: true
},
entry: path.resolve(__dirname, "./src/index.js"),
module:{
rules: [
{
test: /\.js$/,
use:"babel-loader"
},
{
test: /\.css$/,
use:['style-loader', 'css-loader']
}
]
},
output: {
filename: "bundle.js"
}
}
So when I run npm run Build
Its creating a single file bundle.js.
I placed bundle.js in the server static folder
app.get('/',(req,res)=>{
res.sendFile(path.join(__dirname, 'public', 'index.html'))
console.log('welcome')
res.send(req.sessionID)
})
in index.html
<html>
<body>
hello
<script src='./bundle.js'></script>
</body>
</html>
if i try to start the node server. i cant see my browser serving the bundle.js am getting the below error
Uncaught Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200
If this is not the right approach, can anybody suggest a better so that i can deploy both my client and server code in heroku.