Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !12755

feat: support automatic public path

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/amcgee/feat-auto-publicpath into main 2 years ago
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 3

Created by: amcgee

This solution is incomplete - it will unfortunately need to touch a many more places in several packages to work in all cases.

WebPack 5 includes support for automatically determining the public path by passing publicPath='auto'. This change adds support for PUBLIC_URL="auto" or for including "homepage" = "auto" in package.json. When "auto" is specified, webpack is configured with publicPath='auto' and the resulting webpack build will automatically determine the base path on load.

This is useful when the root path is not known at build time. It has been possible to specify PUBLIC_URL=. which correctly resolves most resources relative to the root index.html - however, in some cases (for example when launching a WebWorker) this causes issues when a script attempts to reference another script with a path relative to the base path - with PUBLIC_URL=. the second script resolves to a path relative to the first script rather than relative to index.html.

It might be worth considering making "auto" the default public path value (instead of "/") when neither homepage nor PUBLIC_URL are specified. This should be a non-breaking change (and should reduce the need for specifying this configuration at all) but I opted for leaving it out of this change to keep the surface area small. I would suggest that after this has been used as an opt-in configuration for some time it could be promoted to the default in a future release of Create React App.

This allows PUBLIC_URL=auto as a workaround solution for #12503

Loading
Loading

Activity


  • Administrator requested review from @root 2 years ago

    requested review from @root

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: facebook-github-bot

    Hi @amcgee!

    Thank you for your pull request and welcome to our community.

    Action Required

    In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

    Process

    In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

    Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

    If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

  • Administrator mentioned in issue #12503 2 years ago

    mentioned in issue #12503

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: facebook-github-bot

    Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

  • Administrator added CLA Signed label 2 years ago

    added CLA Signed label

  • Administrator
    Administrator @root · 2 years ago
    Author Contributor

    Created by: amcgee

    This is unfortunately an incomplete solution - PUBLIC_URL is used for index.html template substitutions and webpack's publicPath is also assumed to be a path in several CRA webpack plugins.

    setting publicPath: 'auto' directly in webpack.config.js works better, but may clash with custom publicPath handling in i.e. InlineChunkHtmlPlugin

  • Administrator restored source branch github/fork/amcgee/feat-auto-publicpath 2 years ago

    restored source branch github/fork/amcgee/feat-auto-publicpath

Please register or sign in to reply
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: koush/AndroidAsync!126
Source branch: github/fork/amcgee/feat-auto-publicpath

Menu

Explore Projects Groups Snippets