Webpack-dev-server: How can I serve static files (like contentBase) before proxy?

Created on 23 Feb 2017  ·  2Comments  ·  Source: webpack/webpack-dev-server

I have some config like this:

module.exports = {
  ...

  devServer: {
    contentBase: "./static",
    proxy: {
      "/": { ... },
    },
  },
};

This works well with webpack outputs, but not files in contentBase.
Is there anyway let it work?

All 2 comments

你的配置错了,需要配置一个

    devServer: {

        publicPath: '/static/dist', //这个地址必须与服务端地址相同,才能从内存中获取
        proxy: {
            '/': {
                target: 'xxxxx.com',
                secure: false
            }
        }
    }

Translation of @1021683053 's comment: "Your configuration is wrong, need to configure one" and

// This address must be the same as the server address in order to be retrieved from memory

Looks like that's a solid workaround.

Was this page helpful?
0 / 5 - 0 ratings