Answer the question
In order to leave comments, you need to log in
Express doesn't load React's bundel.js, what's wrong?
After running Express, the front-end does not load and the error "Uncaught SyntaxError: Unexpected token <" is displayed in the console.
Please tell me what is wrong!
I load the frontend in this way: app.use(express.static('./client'));
Here is my webpack config:
var webpack = require('webpack');
var path = require('path');
module.exports = {
devtool: "source-map"
entry: "./client/main.js",
output: {
path: path.resolve(__dirname, 'public/build'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: [/node_modules/, /public/],
loader: 'babel',
query: {
presets:['es2015', 'react']
}
},
{
test: /\.jsx$/,
exclude: [/node_modules/, /public/],
loader: 'babel',
query: {
presets:['es2015', 'react']
}
},
{
test: /\.css$/,
exclude: [/node_modules/, /public/],
loaders: ['style', 'css']
},
{
test: /\.scss$/,
exclude: [/node_modules/],
loaders: ["style", "css?sourceMap", "sass?sourceMap"]
}
]
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question