mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-26 06:59:52 +03:00

BREAKING CHANGE: Now only one tag will be published: `latest`. This tag will include both the standard and latest version
26 lines
712 B
JavaScript
26 lines
712 B
JavaScript
import fs from 'fs';
|
|
|
|
const useref = /<!--\s*build:([a-z]+) ([-a-zA-Z./]+)\s*-->(.*?)<!--\s*endbuild\s*-->/ms;
|
|
|
|
const generateBalise = (type, output, body, opts = {}) => {
|
|
switch (type) {
|
|
case 'css':
|
|
return `<link href="${output}" rel="stylesheet" type="text/css">`;
|
|
case 'js':
|
|
return `<script src="${output}"></script>`;
|
|
case 'keep':
|
|
return opts[output] ? body : '';
|
|
}
|
|
};
|
|
|
|
export default function (src, opts) {
|
|
let html = fs
|
|
.readFileSync(src)
|
|
.toString()
|
|
.replace(/>\n+\s*/g, '>');
|
|
while (useref.test(html)) {
|
|
const [raw, type, output, body] = useref.exec(html);
|
|
html = html.replace(raw, generateBalise(type, output, body, opts));
|
|
}
|
|
return html;
|
|
}
|