diff options
author | silverwind <me@silverwind.io> | 2023-03-15 22:15:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 17:15:12 -0400 |
commit | 19cbd5c3d9893647d85f7fc5b873059d1d6d436d (patch) | |
tree | f675e1b333709d85f6775a5d468c1f7eb8d0e8d3 /webpack.config.js | |
parent | 25ed8c25f3def4573d608d86e3acc5f96ae2b695 (diff) | |
download | gitea-19cbd5c3d9893647d85f7fc5b873059d1d6d436d.tar.gz gitea-19cbd5c3d9893647d85f7fc5b873059d1d6d436d.zip |
Fix theme-auto loading (#23504)
Fix regression from https://github.com/go-gitea/gitea/pull/23481.
The conditional on the CSS import was being stripped away by webpack's
`css-loader`, resulting in the dark theme always loading. The old syntax
with `@import` nested inside `@media` also did not work as `css-loader`
(rightfully) ignores such non-standard `@import` syntax that was
previously supported by Less.
Unfortunately, we have to re-introduce postcss to the CSS pipeline to
fix this and I loaded only the minimal plugins to make it work.
There is one variant of the fix that does work without postcss, which is
to exclude the file from transpilation but I did not consider it as it
would have meant the `@import` was being done without a version suffix
in the URL, which would have caused cache issue.
Related: https://github.com/webpack-contrib/css-loader/issues/1503
---------
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/webpack.config.js b/webpack.config.js index ec8a195940..69a306a024 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -145,10 +145,23 @@ export default { loader: 'css-loader', options: { sourceMap: true, + importLoaders: 1, url: {filter: filterCssImport}, import: {filter: filterCssImport}, }, }, + { + loader: 'postcss-loader', /* for conditional import in theme-auto.css */ + options: { + sourceMap: true, + postcssOptions: { + plugins: [ + 'postcss-import', + 'postcss-url', + ], + }, + }, + }, ], }, { |