uni-ticket-system/node_modules/@dcloudio/uni-h5-vite/dist/plugin/transformIndexHtml/index.js

26 lines
971 B
JavaScript
Raw Normal View History

2023-12-05 02:11:10 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTransformIndexHtml = void 0;
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
function createTransformIndexHtml() {
return async function (html) {
const manifestJson = (0, uni_cli_shared_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
const title = manifestJson.h5?.title || manifestJson.name || '';
return {
html: html.replace(/<title>(.*?)<\/title>/, `<title>${title}</title>`),
tags: process.env.NODE_ENV === 'development'
? [
{
tag: 'script',
children: `if (typeof globalThis === 'undefined') {
window.globalThis = window
}`,
injectTo: 'head-prepend',
},
]
: [],
};
};
}
exports.createTransformIndexHtml = createTransformIndexHtml;