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 <matti@mdranta.net>
This commit is contained in:
silverwind 2020-01-25 09:41:34 +01:00 committed by Lunny Xiao
parent 89f7dcb13d
commit 5b17bb8f3d
6 changed files with 690 additions and 57 deletions

View file

@ -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(/\/[^/]*?\/[^/]*?$/, '/');
}