manifestJson.js 974 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniManifestJsonPlugin = void 0;
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
function uniManifestJsonPlugin() {
fxy060608's avatar
fxy060608 已提交
6
    let manifestJson;
fxy060608's avatar
fxy060608 已提交
7 8 9 10 11 12 13 14
    return uni_cli_shared_1.defineUniManifestJsonPlugin((opts) => {
        return {
            name: 'vite:uni-app-manifest-json',
            enforce: 'pre',
            transform(code, id) {
                if (!opts.filter(id)) {
                    return;
                }
fxy060608's avatar
fxy060608 已提交
15 16 17 18 19 20 21 22 23
                manifestJson = uni_cli_shared_1.normalizeAppManifestJson(JSON.parse(code));
                return '';
            },
            generateBundle() {
                this.emitFile({
                    fileName: `manifest.json`,
                    type: 'asset',
                    source: JSON.stringify(manifestJson, null, 2),
                });
fxy060608's avatar
fxy060608 已提交
24 25 26 27 28
            },
        };
    });
}
exports.uniManifestJsonPlugin = uniManifestJsonPlugin;