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

Add publicPath for static js #1672

Merged
merged 2 commits into from
Jun 29, 2023
Merged

Conversation

sunaurus
Copy link
Collaborator

With the current webpack configuration, Lemmy tries to load js files from paths where there aren't any, creating errors like:

Unhandled Promise Rejection: ChunkLoadError: Loading chunk node_modules_date-fns_esm_locale_en-GB_index_js failed.
(missing: http://localhost:1234/js/node_modules_date-fns_esm_locale_en-GB_index_js.client.js)

Notice that it's loading from /js/... and not /static/js/...

This PR adds a publicPath config, which can be used to specify a base path for assets: https://webpack.js.org/guides/public-path/

As far as I can tell, this fixes #1657 (at least it fixes it for me locally).

Note: I also noticed that the regex for including assets for the ServiceWorkerPlugin was only includiding client.js, I changed it to include all paths in the js/ directory.

@sunaurus
Copy link
Collaborator Author

sunaurus commented Jun 28, 2023

By the way, I'm not exactly sure what the context is with date-fn locale issues (is it a totally unrelated issue?), but this PR should fix loading date-fn files for locales other than en-US as well.

Edit: I found this - #1574 - seems to be the exact same issue. In fact, #1657 is most likely a duplicate of #1574.

Copy link
Contributor

@alectrocute alectrocute left a comment

Choose a reason for hiding this comment

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

@SleeplessOne1917 Are you still planning on replacing date-fns with moment.js? If so, how does that change the proposal here? Still needed?

@SleeplessOne1917
Copy link
Member

Are you still planning on replacing date-fns with moment.js? If so, how does that change the proposal here? Still needed?

I haven't gotten around to removing it yet, but if this PR works I'd much prefer it over bringing back the moment.js dependency. I'll test it tonight.

@alectrocute
Copy link
Contributor

@SleeplessOne1917 I don't think this'll resolve our ongoing timezone issues, unfortunately.

@sunaurus
Copy link
Collaborator Author

sunaurus commented Jun 28, 2023

@alectrocute can I read more about the timezone issue anywhere? Maybe I can take a look at it as well

@SleeplessOne1917
Copy link
Member

can I read more about the timezone issue anywhere? Maybe I can take a look at it as well

The issues you linked earlier would be the best place to look, though it seems you've already done that.

@alectrocute since the imports are fixed, getting the timezones working might actually be possible.

@dessalines dessalines merged commit 0764b75 into LemmyNet:main Jun 29, 2023
@sunaurus sunaurus deleted the webpack_public_path branch June 29, 2023 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants