Skip to content

fix(devserver) Remove "prod" requirement for using publicPath #4962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2019
Merged

fix(devserver) Remove "prod" requirement for using publicPath #4962

merged 2 commits into from
Aug 30, 2019

Conversation

EEParker
Copy link
Contributor

@EEParker EEParker commented Aug 23, 2019

This PR allows publicPath and the base tag to work on dev builds. It is used in conjunction with webpackDevServer publicPath.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Documentation
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Fixes #4840, #4687

quasar.conf.js

    build: {
      publicPath: '/path/to/app1/', 
      forceDevPublicPath: true, // this allows publicPath to work in dev and prod builds
      vueRouterMode: 'history',
    },

    devServer: {
      publicPath: '/app1/', // this can match the publicPath from above or be part of the subpath. If using a proxy, set it to match.
    },

@EEParker EEParker changed the title Remove "prod" requirement for using publicPath fix(devserver) Remove "prod" requirement for using publicPath Aug 23, 2019
@hawkeye64
Copy link
Member

@EEParker I don't believe they shouild match. Very rarely does a developer computer match the same set up as a production server.

@EEParker
Copy link
Contributor Author

@hawkeye64 perhaps not, and in my test case with aspdotnet I am using different paths. However, within my test project where quasar is a "child" application, the base tag does needs to match what aspdotnet expects the route to be to work. This patch allows it to work in development and hmr to function.

@hawkeye64
Copy link
Member

hawkeye64 commented Aug 26, 2019

@EEParker I am just saying don't assume they should match. Based on this:

// this should match the publicPath from above

@rstoenescu
Copy link
Member

Hi @EEParker ,

Thanks for contributing!

I cannot merge this as it would break some Quasar modes. However, what we could do is setup a new Boolean flag under quasar.conf.js > build, name it "forceDevPublicPath", then scenarios like yours can be covered too.

I'm just wondering over the very large implications of this. Were you able to test the changes in this PR? Need help getting you up to speed on testing CLI changes?

Also, would need some doc updates for the new flag. Again, I can show you quickly how to do it (ping me on Discord) -- if this is unclear how to do. Should be a 1-2 minute thing to add this to docs.

@EEParker
Copy link
Contributor Author

@rstoenescu Thanks for the feedback. I did test spa and pwa modes, however I did not test Electron or Cordova builds or really consider the implications. Your suggestion of a forceDevPublicPath would work for the use case I was targeting. In fact it sounds like it would effectively accomplish what is proposed by #4840. I will work on a PR for the flag and docs.

@@ -711,7 +712,7 @@ class QuasarConfig {
}
}
else {
cfg.build.env.__statics = `"${this.ctx.dev ? '/' : cfg.build.publicPath || '/'}statics"`
cfg.build.env.__statics = `"${((this.ctx.prod || cfg.build.forceDevPublicPath) && cfg.build.publicPath) ? cfg.build.publicPath : '/' }statics"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the logic here to match L478.

@rstoenescu rstoenescu merged commit 1fb3c59 into quasarframework:dev Aug 30, 2019
@rstoenescu
Copy link
Member

Merged it and pushed a subsequent commit to bulletproofed it.

@EEParker Thanks for starting this and taking time for it for a PR! Much appreciate it.
Will be available in quasar/app 1.0.6 shortly.

@EEParker EEParker deleted the patch-1 branch September 3, 2019 13:26
mesqueeb pushed a commit to mesqueeb/quasar that referenced this pull request Feb 2, 2020
…framework#4962)

* add option to force publicPath in 'dev' builds

* Update quasar-conf-js.md
mesqueeb pushed a commit to mesqueeb/quasar that referenced this pull request Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exposing build.appBase variables for user-defined configuration
3 participants