diff options
author | silverwind <me@silverwind.io> | 2020-04-13 15:02:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 16:02:31 +0300 |
commit | 27e3cddfbef533f783898800ac4abdd5a453b436 (patch) | |
tree | 1ba9f63c9fac2f06549a28e043c3669042cf9ced /webpack.config.js | |
parent | cc4da79fb6302f35dfe9e2d5af7cda384083b0af (diff) | |
download | gitea-27e3cddfbef533f783898800ac4abdd5a453b436.tar.gz gitea-27e3cddfbef533f783898800ac4abdd5a453b436.zip |
Move syntax highlighting to web worker (#11017)
This should eliminate page freezes when loading big files/diff.
`highlightBlock` is needed to preserve existing nodes when highlighting
and for that, highlight.js needs access to the DOM API so I added a DOM
implementation to make it work, which adds around 300kB to the output
file size of the lazy-loaded `highlight.js`.
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/webpack.config.js b/webpack.config.js index 57a41a11a7..77680cb379 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -51,6 +51,7 @@ module.exports = { sourceMap: true, extractComments: false, terserOptions: { + keep_fnames: /^(HTML|SVG)/, // https://github.com/fgnass/domino/issues/144 output: { comments: false, }, @@ -90,6 +91,19 @@ module.exports = { use: 'imports-loader?define=>false,exports=>false', }, { + test: /\.worker\.js$/, + use: [ + { + loader: 'worker-loader', + options: { + name: '[name].js', + inline: true, + fallback: false, + }, + }, + ], + }, + { test: /\.js$/, exclude: /node_modules/, use: [ |