How to bundle a React app to a subdirectory on a server?

前端 未结 10 2143
名媛妹妹
名媛妹妹 2020-12-04 14:41

I have a React app I\'ve been developing on my localhost. I want to copy it to a server into a subdirectory called vensa.

My webpack config file looks like this..

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 15:07

    Use the html-webpack-plugin to generate your final index.html with the correct bundle names automatically injected into it.

    Then set output.publicPath in your webpack config to tell webpack the subdirectory your assets will be deployed to:

    output: {
      path: 'build',
      publicPath: "/vensa/",
      filename: 'bundle.js'
    },
    

提交回复
热议问题