From 5b17bb8f3dbc180c72446000d82ba06fd7349dc7 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 25 Jan 2020 09:41:34 +0100 Subject: add css extraction and minification to webpack (#9944) This changes the CSS output of webpack to output to the public/css directory instead of inling CSS in JS. This enables CSS minification and autoprefixer based on browserslist which would otherwise not be possible. The result of this change is two new output files currently: - public/css/swagger.css - public/css/gitgraph.css Co-authored-by: techknowlogick --- web_src/js/publicPath.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'web_src') diff --git a/web_src/js/publicPath.js b/web_src/js/publicPath.js index 5d277e442a..120740d708 100644 --- a/web_src/js/publicPath.js +++ b/web_src/js/publicPath.js @@ -1,12 +1,11 @@ -/* This sets up webpack's chunk loading to load resources from the same - directory where it loaded index.js from. This file must be imported - before any lazy-loading is being attempted. */ +/* This sets up webpack's chunk loading to load resources from the 'public' + directory. This file must be imported before any lazy-loading is being attempted. */ if (document.currentScript && document.currentScript.src) { const url = new URL(document.currentScript.src); - __webpack_public_path__ = `${url.pathname.replace(/\/[^/]*$/, '')}/`; + __webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/'); } else { // compat: IE11 const script = document.querySelector('script[src*="/index.js"]'); - __webpack_public_path__ = `${script.getAttribute('src').replace(/\/[^/]*$/, '')}/`; + __webpack_public_path__ = script.getAttribute('src').replace(/\/[^/]*?\/[^/]*?$/, '/'); } -- cgit v1.2.3