juwiley juwiley - 1 year ago 95
React JSX Question

Webpack defaulting to /public directory

I have a React app I'm porting to Webpack, and I can successfully launch it using webpack-dev-server.

Unfortunately I have to navigate to the public directory to load the app:


...which interferes with React router. Is it possible to have it mount to / instead? I.e:


The publicPath directive in output doesn't seem to influence this.

// webpack.config.js
module.exports = {
devServer: {
inline: true,
port: 10000 // Defaults to 8080
entry: {
app: ['./src/app.jsx']
devtool: 'source-map',
resolve: {
extensions: ['', '.js', '.jsx']
output: {
path: path.resolve(__dirname, "public/scripts"),
publicPath: '/scripts/',
filename: 'bundle.js'
module: {
loaders: [
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
plugins: [

Answer Source

Try setting the contentBase to public folder


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download