2

I am serving my compiled app with Tomcat. The app is not served from the root context but with a suffix - e.g. mysite.com/myapp.

I need webpack to add this myapp prefix to the js and css imports in index.html.

I need this:

<html>
<head>
  <link rel="shortcut icon" href="/myapp/favicon.ico">
  <link href="/myapp/app.9c885d75239355add0ca8f22362e289c.css" rel="stylesheet">
</head>
<body>
  <div id="root"></div>
  <script src="/myapp/vendor.1c28bcf2a2efacc7d62d.js"></script>
  <script src="/myapp/app.d678b996583f01bd2f7d.js"></script>
</body>
</html>

But right now I have this:

<html>
<head>
  <link rel="shortcut icon" href="favicon.ico">
  <link href="app.9c885d75239355add0ca8f22362e289c.css" rel="stylesheet">
</head>
<body>
  <div id="root"></div>
  <script src="vendor.1c28bcf2a2efacc7d62d.js"></script>
  <script src="app.d678b996583f01bd2f7d.js"></script>
</body>
</html>

A hacky way would be to run a script during the build to change the links but I would like to have a more proper webpack solution.

I'm using HtmlWebpackPlugin and React Redux Starter Kit.

2 Answers 2

1

Set

output: {
  filename: '/myapp/[name].[chunkhash].js',
  ...
},
Sign up to request clarification or add additional context in comments.

Comments

1

I guess we can also use Webpack publicPath

output: {
  publicPath: '/myapp/',
  ...
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.