提交 1d3f7ba5 编写于 作者: fxy060608's avatar fxy060608

fix(cli): preprocess pages.json

上级 5ec7a426
import fs from 'fs'
import path from 'path'
import slash from 'slash'
import { parse } from 'jsonc-parser'
import {
CreateUniViteFilterPlugin,
UniViteFilterPluginOptions,
......@@ -52,7 +51,7 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
if (!opts.filter(id)) {
return
}
return JSON.stringify(parse(fs.readFileSync(jsonPath, 'utf8')))
return fs.readFileSync(jsonPath, 'utf8')
}
return plugin
}
......
......@@ -23,7 +23,7 @@ function uniManifestJsonPlugin() {
if (!opts.filter(id)) {
return;
}
const manifest = JSON.parse(code);
const manifest = uni_cli_shared_1.parseJson(code);
const { debug, h5 } = manifest;
const appid = (manifest.appid || '').replace('__UNI__', '');
const router = Object.assign(Object.assign({}, defaultRouter), ((h5 && h5.router) || {}));
......
......@@ -3,6 +3,7 @@ import { Plugin } from 'vite'
import {
defineUniManifestJsonPlugin,
normalizeNetworkTimeout,
parseJson,
} from '@dcloudio/uni-cli-shared'
const defaultRouter = {
......@@ -29,7 +30,7 @@ export function uniManifestJsonPlugin(): Plugin {
if (!opts.filter(id)) {
return
}
const manifest = JSON.parse(code)
const manifest = parseJson(code)
const { debug, h5 } = manifest
const appid = (manifest.appid || '').replace('__UNI__', '')
const router = { ...defaultRouter, ...((h5 && h5.router) || {}) }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册