Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Using baseUrl for react-router & code splitting #486

Closed
@MrCrimp

Description

@MrCrimp

Continuation of #425
First, great call to make baseUrl part of the default parameters.

For the react-redux template, to make use of baseUrl it's necessary to modify boot-client.ts a bit, you'll probably want

// instruct the router to ignore that part when resolving routes so they can be defined without taking baseUrl into account
const history = useRouterHistory(createHistory)({
     basename: baseUrl
   });

Those <LinkTo/> components should then work as expected


Now, for the webpack and public path when using code splitting.

The scenario is that you do e.g

function loadLocale(){
  require.ensure([], (require) => {
      const request: any = require( 'bundle-loader?lazy!react-intl/locale-data/' + locale );
     //.....

Given that webpack public path now is absolute path /dist/ and in your code you do a
call to loadLocale() then webpack will issue a request to
yourserver.com/dist/1.js no matter what, when what you really wanted was yourserver.com/vdir/dist/1.js

So I think it's necessary to prepend the newly introduced baseUrl when setting webpack.public path in aspnet-webpack code, instead of forcing it to absolute e.g /dist/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions