Commit Graph

110 Commits

Author SHA1 Message Date
7e52eada20 FIX: Use Terser for minification even if uglify-js is not available (#13683) 2021-07-14 14:20:57 +08:00
95b5794331 DEV: Compile core and plugin stylesheets independently of themes (#13638)
Take 2 of https://github.com/discourse/discourse/pull/13466. 

Fixes a few issues with the original PR: 

- color definition stylesheet target now includes the theme id, to avoid themes set to use the default color scheme loading the same stylesheet 
- changes the internal cache key for color definition stylesheet to reset the pre-existing cache
2021-07-06 13:11:10 -04:00
02999f5eb2 Skip compressing theme test files (#13619) 2021-07-02 12:16:16 -04:00
128fdf9d9c DEV: Revert stylesheet refactors (#13584)
* Revert "FIX: Clear appropriate cache when updating font settings (#13582)"

This reverts commit de6cc7a92412538b2460e1b6f4855da343054899.

* Revert "DEV: Improve output of `Stylesheet::Mananger.precompile_theme_css`."

This reverts commit 95038856c9ddeee7d0d8083a75006a5e3492dd54.

* Revert "FIX: Child themes being precompiled multiple times."

This reverts commit 6986b36985fa242cb3d346b05f84d3878573c354.

* Revert "Update spec/components/stylesheet/manager_spec.rb"

This reverts commit ddaa7cc7eac2850f9a8614077c1170942ebc0311.

* Revert "Refactor scss live refreshing"

This reverts commit a838293aaf1e3b21c34c1964603e1b85c5673935.

* Revert "Precompile core stylesheets independently of themes"

This reverts commit 99d259d39bdaade6d20951c84def890dc91246a5.

* Revert "DEV: Add simple digest for core stylesheets"

This reverts commit d82c58e6cc5dd43b8bfb062838a24cac85ac9ca2.
2021-06-30 21:33:15 +08:00
99d259d39b Precompile core stylesheets independently of themes 2021-06-30 13:42:40 +08:00
58cb120aa2 DEV: Minor code clean up in assets.rake. (#13245) 2021-06-03 11:37:06 +10:00
9118bb2076 FEATURE: Normalize the service worker route (#12343)
Re-lands the change initially proposed on #8359 but without a new nginx
location block, so it has less change surface.

Co-authored-by: Jeff Wong <awole20@gmail.com>

Co-authored-by: Jeff Wong <awole20@gmail.com>
2021-05-25 19:39:31 -03:00
e77b9dfd45 DEV: Use Terser for JS minification/compression if available (#12656) 2021-04-09 08:51:49 -04:00
Sam
c540bf5e2b FIX: correct cdn path (#11324)
This was a typo in a118ec13
2020-11-23 13:03:49 +11:00
Sam
a118ec13bc FIX: stop including GlobalPath in default context (#11323)
We do not want these method names to clash, instead encapsulate the helpers
so we do not add methods to Kernel

Correct a but exposed by Ruby 2.7
2020-11-23 12:59:45 +11:00
7a0d1cadc5 DEV: Add option to precompile default multisite stylesheets 2020-09-03 13:00:09 -04:00
5f3fd23fa8 DEV: Add stub flush_sw task to prevent rebuild errors (#10021) 2020-06-10 13:07:37 -07:00
6358e79f0f FIX: catch NoMethodError during precompile_css too (#9940)
Ran into this on heroku:

    NoMethodError: undefined method `enabled?' for #<Theme:0x0000558f069e7718>
    vendor/bundle/ruby/2.6.0/gems/activemodel-6.0.1/lib/active_model/attribute_methods.rb:431:in `method_missing'
    app/models/theme.rb:155:in `block (2 levels) in transform_ids'
    vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/delegation.rb:85:in `each'
    vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/delegation.rb:85:in `each'
    vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/query_methods.rb:260:in `select'
    vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/query_methods.rb:260:in `select'
    app/models/theme.rb:155:in `block in transform_ids'
    app/models/theme.rb:105:in `get_set_cache'
    app/models/theme.rb:140:in `transform_ids'
    app/models/theme.rb:321:in `list_baked_fields'
    app/models/theme.rb:317:in `resolve_baked_field'
    lib/stylesheet/manager.rb:289:in `theme_digest'
2020-06-02 15:18:03 +10:00
8eb2147f1f FIX: Ensure sourcemap's source is correct. Uses the full assets path this time. (#8774) 2020-01-23 14:44:00 -03:00
1de5b4ad64 Revert "FIX: Ensure sourcemap's source is correct"
This reverts commit 4553a0f6e07128b71bc2d53ed35c72fbd55c0c90.
2020-01-22 16:31:34 -03:00
4553a0f6e0 FIX: Ensure sourcemap's source is correct 2020-01-22 12:57:28 -03:00
b13f427450 DEV: Drop uglifyJS V2 support 2019-12-04 15:58:38 -03:00
c6d8dbd4a9 Revert "FEATURE: Normalize the service worker route (#8359)"
This reverts commit 9799a651b6ca06dd6a6c7ec42d033ead027d9a34.
2019-11-20 14:10:17 -08:00
9799a651b6 FEATURE: Normalize the service worker route (#8359)
* FEATURE: Normalize the service worker route

Update cache headers so they are not immutable outside of the rails app

Add the ability to purge the service worker cache from localhost

Rails -> nginx will pass immutable flags so the file is cached until reloaded.
In most cases, nginx will have its cache flushed on rebuild (new image)

For those needing dynamic re-caching (such as upgrading via the UI),
a rake task for flushing the service worker script is provided
through `assets:flush_sw`
2019-11-20 11:33:41 -08:00
10478cb395 DEV: Bump uglifyjs (#7834)
* Rewrite uglifyjs command to work with 3.x

* Use ES5 syntax in plain JS files

* Use the older command if uglifyJS V2.x is installed
2019-10-09 10:02:49 -03:00
215216df48 FIX: stop re-downloading backup maxmind
We omitted updating the mmdb_time which changed causing a constant
re-download of the maxmind db
2019-06-13 17:42:26 +10:00
3de8c58134 DEV: clean up backup maxmind path
This follows up on 6580025a

reuses a list and removes a map that was erronuously there.
2019-05-28 11:47:58 +10:00
6580025af9 FEATURE: add backup directory for mmdb files
This new `DISCOURSE_MAXMIND_BACKUP_PATH` can be used a secondary location
for maxmind db. That way a build machine, for example can cache it on the
host and reuse between builds.

Also per 5bfeef77 added proper error raising for download fails from
dedicated rake task

This also moves "refresh_maxmind_db_during_precompile_days" to a global
setting, it did not make sense in a site setting
2019-05-27 16:51:24 +10:00
2f5938c3bf DEV: use FileHelper to download MaxMindDB 2019-05-24 18:11:39 +02:00
8c9ffee3af TEMP: log more information when failing to download db 2019-05-24 17:33:52 +02:00
9ed2c54e27 TEMP: log information when failing to download db 2019-05-24 17:26:04 +02:00
30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
a92c925378 Use faster Brotli compression for non-default locale files 2019-05-08 14:55:24 -04:00
d9ab722d05 Revert "Revert "PERF: Skip compressing locales for faster rebuilds (#7501)" (#7502)"
This reverts commit 6ea811c923c2d96e4d71332c300422653909d890.
2019-05-08 14:55:06 -04:00
6ea811c923 Revert "PERF: Skip compressing locales for faster rebuilds (#7501)" (#7502) 2019-05-08 07:54:21 +02:00
5c0bb29461 DEV: re-enable compression for node asset compilation
#b9d82818 makes enormous improvements to our bootstrap time, however going
to still keep compress for now despite the cost and watch it for a few weeks
2019-05-08 10:24:57 +10:00
b9d8281818 PERF: Skip compressing locales for faster rebuilds (#7501)
* Do not brotli all locales in precompile

* Try without gzip

* uglify without compressing, always gzip

* skip uglify for unused locales

* FIX: Uglifier needs harmony for ES6 compatibility

* Use node uglifier if available

* Minor refactor
2019-05-08 10:22:19 +10:00
84f12ac3f7 DEV: No need to carry two brotli implementations around
old version of brotli binary is long gone, require brotli 1.0.0 and up
2019-04-11 16:53:29 +10:00
baa7a9836c FEATURE: remove "COMPRESS_BROTLI" optional behavior
The compress brotli functionality is no longer optional, this has worked
well for years. The name of the ENV var is also confusing cause it does
not have a `DISCOURSE_` prefix which caused issues with the web upgrader

Brotli support is now unconditionally on
2019-04-11 12:36:18 +10:00
c523a12187 FIX: Fix assets:precompile rake task. 2019-04-10 14:03:26 +03:00
4555d0c598 FEATURE: Refresh MaxmindDb during assets:precompile. (#7340) 2019-04-10 11:37:29 +02:00
bc52437153 FIX: Add additional rescue for assets:precompile
This error can be caused if assets are precompiled before the database has been migrated
2019-03-07 14:03:05 +00:00
d639cadb7a DEV: Plugin scss errors should break precompile (#6974) 2019-02-07 09:27:42 -05:00
77c293f82d Prefer Process.clock_gettime over Time.now. 2018-10-05 10:25:52 +08:00
13dde44c72 FIX: Limit concurrent assets:precompile to number of available cores. 2018-10-03 16:46:21 +08:00
Sam
d1b21aa73b add timings to asset precompile 2018-07-04 09:42:38 +10:00
Sam
89ad2b5900 DEV: Rails 5.2 upgrade and global gem upgrade
This updates tests to use latest rails 5 practice
and updates ALL dependencies that could be updated

Performance testing shows that performance has not regressed
if anything it is marginally faster now.
2018-06-07 14:21:33 +10:00
Sam
5a8d2b5e45 FIX: rake assets:precompile should be re-runnable 2018-05-31 16:18:01 +10:00
45c19e44f0 assets rake task: only try and detect brotli if COMPRESS_BROTLI is set 2017-11-24 12:00:38 -05:00
5584085943 assets rake task: detect the brotli version on the image as the usage changes 2017-11-24 10:40:57 -05:00
3c60702663 assets rake task: gzip and brotli exit codes exist for a reason - to be checked 2017-11-24 09:52:08 -05:00
5012d46cbd Add rubocop to our build. (#5004) 2017-07-28 10:20:09 +09:00
0a478905b9 FIX: ensure we clear emoji cache before recompilation 2017-07-05 10:36:06 +02:00
1dc55bcc5b attempt to handle one more multisite edge case 2017-05-05 13:51:26 -04:00
Sam
4ed4d77fd3 correct the monkey patch 2017-04-14 15:06:52 -04:00