[CHORE] Proper chunking for swagger
- Tell webpack to chunk the swagger-ui dependency, so it can be re-used for the forgejo-swagger.js and swagger.js files (these two files are two seperate javascript files in the output). - This saves off 400KB when Forgejo is built with the `bindata` build tag.
This commit is contained in:
parent
e3243a9465
commit
9eb22ddc19
|
@ -1,7 +1,8 @@
|
|||
import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
|
||||
import 'swagger-ui-dist/swagger-ui.css';
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
const [{default: SwaggerUI}] = await Promise.all([
|
||||
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui-es-bundle.js'),
|
||||
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui.css'),
|
||||
]);
|
||||
const url = document.getElementById('swagger-ui').getAttribute('data-source');
|
||||
|
||||
const ui = SwaggerUI({
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
|
||||
import 'swagger-ui-dist/swagger-ui.css';
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
const [{default: SwaggerUI}] = await Promise.all([
|
||||
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui-es-bundle.js'),
|
||||
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui.css'),
|
||||
]);
|
||||
|
||||
const url = document.getElementById('swagger-ui').getAttribute('data-source');
|
||||
const res = await fetch(url);
|
||||
const spec = await res.json();
|
||||
|
|
Loading…
Reference in New Issue