Configure webpack-dev-server to play nice with different existing vhosts for assets and application

Viewed 2694

I am trying to set up non-standard webpack-dev-server proxy configuration.

Following reading: http://webpack.github.io/docs/webpack-dev-server.html#combining-with-an-existing-server

Basically my local web server web root is: http://website.dev and my local asset server is http://website.assets

I want to configure webpack-dev-server to proxy my existing site served from http://website.dev and proxy its' javascript assets which would be served from http://website.assets.

Here's what I've tried:

var webpackConfig = {
        output: {
            path: '../dist/js',
            publicPath: 'http://website.assets/js/',
            filename: '[name].js'
        },
        devServer: {
            //publicPath: '',
            contentBase: 'http://website.dev',
            proxy: {
                'js/*': {
                    target: "http://website.assets/js"
                }
            }
        }
    };

and

var webpackConfig = {
        output: {
            path: '../dist/js',
            publicPath: 'http://website.assets/js/',
            filename: '[name].js'
        },
        devServer: {
            publicPath: 'http://website.assets/js/',
            contentBase: 'http://website.dev'
        }
    };

and

var webpackConfig = {
        output: {
            path: '../dist/js',
            publicPath: 'http://website.assets/js/',
            filename: '[name].js'
        },
        devServer: {
            publicPath: 'http://website.assets/js/',
            proxy: {
                '*': "http://website.dev",
                'js/*': "http://website.assets/js/"
            }
        }
    };

I can't figure out how to get the configuration to play nice with my permutation. I'm not confident that my devServer configuration is correct. Please help :)

1 Answers
Related