I'm trying to start react-js app with node server. Structure of directory: MyTodo
---bin/
------css/
------fonts/
------js/
------index.html
---sources/
------App.jsx
------TodoGroup/
file server.js:
var express=require('express');
var app=express();
app.set('port',(process.env.PORT||3000));
app.use('/',express.static(__dirname));
app.listen(app.get('port'), function() {
console.log('Server started: http://localhost:'+app.get('port')+'/');
});
webpack.config:
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var config = module.exports = {
context: __dirname,
entry: {
'App': './sources/App.jsx',
},
output: {
path: './bin/js',
filename: '[name].js'
},
plugins: [
new ExtractTextPlugin('../css/[name].css')
],
devServer: {
contentBase: ".",
host: "localhost",
port: 3000
},
module:{
loaders:[ //загрузчики
{
test: /\.jsx?$/, // определяем тип файлов
exclude: /(node_modules)/,
loader: "babel-loader",
query:{
presets:["es2015", "react"]
}
}
]
}
resolve: {
extensions: ['', '.js', '.jsx']
}
}
In browser http://localhost:3000/ shows an error: GET http://localhost:3000/ 404 (Not Found)
server.js
? Assuming it is in parent ofbin/
, then update theapp.use('/',express.static(path.join(__dirname, "bin/")));
Importpath
too. – Mukesh Sharma