How to collect all static assets (js, css) used by discourse

Thank you so much. I also found that some static assets (like CSS) are put in /var/www/discourse/tmp/stylesheet-cache.But there are two other problems:

  1. Users upload assets like avatar also serve by the CDN after setting up DISCOURSE_CDN_URL. However, push the upload assets to Github after every time user upload seems not a great solution.
  2. When discourse requesting user_avatar like 2_2.png. It will 1) split the file name, 2) do some check, 3) calculate the real file name using hashing. If I need to serve user avatar I have to implement the same logic myself since there is no file named 2_2.png.

My final solution is simple. 1) I add Nginx before my forum like this post. 2) Collect all the static assets from the above path and push them to Github. 3) In Nginx config file, add some rules like

location ~/(stylesheets|assets) {
    return 301 https://cdn.jsdelivr.net/gh/my_github/my_repo/$request_uri;
}

Thank you again @schleifer

1 Like