Skip to content
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

CSS refers to webfonts through an absolute path. #1747

Closed
guusdk opened this issue Oct 8, 2019 · 6 comments
Closed

CSS refers to webfonts through an absolute path. #1747

guusdk opened this issue Oct 8, 2019 · 6 comments

Comments

@guusdk
Copy link
Member

guusdk commented Oct 8, 2019

converse.css and converse.min.css refer to the webfont location using an absolute path (under /dist/webfonts/

This makes it problematic to host Converse on a webserver in a context root other than one that is called 'dist'.

Please make the webfont location configurable or relative.

guusdk added a commit to guusdk/openfire-inverse-plugin that referenced this issue Oct 8, 2019
This corrects for an unfortunate characteristic of the Converse.js distribution, as tracked in conversejs/converse.js#1747
@joudinet
Copy link
Contributor

joudinet commented Nov 7, 2019

I tried to make this location depends on __webpack_public_path__ variable instead of using the hardcoded /dist but I failed.
This is what I tried:

I've added the two following lines to webpack.common.js:

publicPath: 'webfonts/',
postTransformPublicPath: (p) => `__webpack_public_path__ + ${p}`

Unfortunately, make dist continues to generate a css file with hardcoded /dist in the webfont location :-(

@allo-
Copy link

allo- commented Jan 22, 2020

The issue is still present in 6.0.0 and I would like to use it with relative paths, too.

@jcbrand
Copy link
Member

jcbrand commented Jan 23, 2020

I'm not sure what can/should be done to fix this.

Here's a relevant webpack issue: webpack-contrib/css-loader#155

From that issue:

To use a runtime public path:

You must not use the extract-text-webpack-plugin.
You must set webpack_public_path before referencing the stylesheets or images. (ES6 imports is moved to the top, be careful. Best use a extra file for setting the runtime path)

We already do that AFAICT, in src/entry.js.

@jcbrand
Copy link
Member

jcbrand commented Feb 13, 2020

As a workaround, you can build your own dist files and then specify the ASSET_PATH to be used for the webfonts.

Like this: ASSET_PATH=https://example.org/dist/ make dist

jcbrand added a commit that referenced this issue Feb 13, 2020
Don't rewrite the urls for assets loaded via `url()` in CSS.

Instead, they should be relative to the CSS file.
@jcbrand jcbrand added this to the 6.0.1 milestone Feb 13, 2020
@jcbrand
Copy link
Member

jcbrand commented Feb 13, 2020

I've made a fix to not rewrite url() paths in CSS. That means that assets are now loaded relative to the CSS file itself, which I believe resolves this issue.

jcbrand added a commit that referenced this issue Feb 13, 2020
Don't rewrite the urls for assets loaded via `url()` in CSS.

Instead, they should be relative to the CSS file.
@joudinet
Copy link
Contributor

Great, thanks. I'll test it when 7f69394 will be included in a release.

@jcbrand jcbrand closed this as completed Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants