webpack-dev-server --open to a specific path?
You can also try the before
option:
module.exports = {
//...
devServer: {
before: function(app, server) {
app.get('/', function(req, res) {
res.redirect('/app'); // here you can try any of the Express JS res options mentioned in the answer below:
});
}
}
};
Documentation for Express.js response
Good Luck...
v4
Use devServer.open:
npx webpack serve --open /app
or
module.exports = {
// ...
devServer: {
open: ['/app'],
// ...
},
}
v3
Use devServer.openPage.
In your case the value would be /app
.
You can also rewrite a bit of your config so you don't have to pass cli commands.
output: {
publicPath: '/app', // deploy on server with /app/ folder name
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'public')
},
devServer: {
contentBase: './dist',
host: 'localhost',
port: '3000',
inline: true,
compress: true,
proxy: {
'/api/**': {
target: 'http://10.189.1.159:8080',
secure: false,
changeOrigin: true,
cookieDomainRewrite: true
}
}
open: true, // Here
openPage: '/app' // And here
},