提交 470cc0bc 编写于 作者: fxy060608's avatar fxy060608

feat(mp): custom project.config.json

上级 8f798176
......@@ -13,9 +13,11 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var component2 = true;
var enableAppxNg = true;
var enableNodeModuleBabelTransform = true;
var source = {
component2: component2,
enableAppxNg: enableAppxNg
enableAppxNg: enableAppxNg,
enableNodeModuleBabelTransform: enableNodeModuleBabelTransform
};
function transformRef(node, context) {
......@@ -222,6 +224,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['mini.project.json', 'project.my.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { customElements, filter: {
......
{
"component2": true,
"enableAppxNg": true
"enableAppxNg": true,
"enableNodeModuleBabelTransform": true
}
......@@ -105,6 +105,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: projectConfigFilename,
config: ['mini.project.json', 'project.my.json'],
source,
},
template: {
......
......@@ -110,6 +110,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['project.swan.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { customElements, filter: {
......
......@@ -61,6 +61,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: projectConfigFilename,
config: ['project.swan.json'],
source,
},
template: {
......
......@@ -175,6 +175,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['project.ks.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { filter: undefined, extname: '.ksml', compilerOptions }),
......
......@@ -60,6 +60,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: projectConfigFilename,
config: ['project.ks.json'],
source,
},
template: {
......
......@@ -107,6 +107,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['project.tt.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { filter: {
......@@ -145,6 +146,7 @@ options.template.slot.fallbackContent = false;
// 飞书不支持:
// <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view>
options.template.slot.dynamicSlotNames = false;
options.project.config = ['project.lark.json'];
var index = [uniMiniProgramToutiaoPlugin, ...initMiniProgramPlugin__default["default"](options)];
module.exports = index;
......@@ -21,12 +21,10 @@
"main": "dist/uni.compiler.js"
},
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
"devDependencies": {
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3040120220308001"
},
"dependencies": {
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-compiler": "3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-vite": "3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-vue": "3.0.0-alpha-3040120220308001",
"@dcloudio/uni-shared": "3.0.0-alpha-3040120220308001",
......
......@@ -25,4 +25,5 @@ options.template.slot.fallbackContent = false
// 飞书不支持:
// <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view>
options.template.slot.dynamicSlotNames = false
options.project!.config = ['project.lark.json']
export default [uniMiniProgramToutiaoPlugin, ...initMiniProgramPlugin(options)]
......@@ -137,6 +137,7 @@ const options = {
},
project: {
filename: 'project.config.json',
config: ['project.qq.json', 'project.config.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { filter: {
......
......@@ -69,6 +69,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: 'project.config.json',
config: ['project.qq.json', 'project.config.json'],
source,
},
template: {
......
......@@ -107,6 +107,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['project.tt.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { filter: {
......
......@@ -60,6 +60,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: projectConfigFilename,
config: ['project.tt.json'],
source,
},
template: {
......
......@@ -61,6 +61,7 @@ export interface UniMiniProgramPluginOptions {
}
project?: {
filename: string
config: string[]
source: Record<string, any>
}
template: {
......
import fs from 'fs'
import path from 'path'
import { Plugin } from 'vite'
import { hasOwn } from '@vue/shared'
import {
defineUniManifestJsonPlugin,
getLocaleFiles,
parseJson,
parseMiniProgramProjectJson,
parsePagesJsonOnce,
} from '@dcloudio/uni-cli-shared'
import { UniMiniProgramPluginOptions } from '../plugin'
function findUserProjectConfigFile(inputDir: string, config: string[]) {
for (let i = 0; i < config.length; i++) {
const projectFilename = path.resolve(inputDir, config[i])
// 根目录包含指定文件,则直接拷贝
if (fs.existsSync(projectFilename)) {
return projectFilename
}
}
}
export function uniManifestJsonPlugin(
options: UniMiniProgramPluginOptions
): Plugin {
let projectJson: Record<string, any>
let userProjectFilename: string | undefined
return defineUniManifestJsonPlugin((opts) => {
const inputDir = process.env.UNI_INPUT_DIR
const platform = process.env.UNI_PLATFORM
if (options.project) {
userProjectFilename = findUserProjectConfigFile(
inputDir,
options.project.config
)
}
return {
name: 'uni:mp-manifest-json',
enforce: 'pre',
......@@ -21,34 +42,40 @@ export function uniManifestJsonPlugin(
if (!opts.filter(id)) {
return
}
const inputDir = process.env.UNI_INPUT_DIR
const platform = process.env.UNI_PLATFORM
this.addWatchFile(path.resolve(inputDir, 'manifest.json'))
getLocaleFiles(path.resolve(inputDir, 'locale')).forEach((filepath) => {
this.addWatchFile(filepath)
})
if (options.project) {
const template = options.project.source
if (hasOwn(template, 'appid')) {
let projectname = path.basename(inputDir)
if (projectname === 'src') {
projectname = path.basename(path.dirname(inputDir))
}
template.projectname = projectname
// TODO condition
if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
if (!template.setting) {
template.setting = {}
// 根目录包含指定文件,则直接拷贝
if (userProjectFilename) {
this.addWatchFile(userProjectFilename)
projectJson = parseJson(
fs.readFileSync(userProjectFilename, 'utf8')
)
} else {
const template = options.project.source
if (hasOwn(template, 'appid')) {
let projectname = path.basename(inputDir)
if (projectname === 'src') {
projectname = path.basename(path.dirname(inputDir))
}
template.setting.urlCheck = false
template.projectname = projectname
// TODO condition
if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
if (!template.setting) {
template.setting = {}
}
template.setting.urlCheck = false
}
projectJson = parseMiniProgramProjectJson(code, platform, {
template,
pagesJson: parsePagesJsonOnce(inputDir, platform),
})
} else {
// 无需解析,直接拷贝,如 quickapp-webview
projectJson = template
}
projectJson = parseMiniProgramProjectJson(code, platform, {
template,
pagesJson: parsePagesJsonOnce(inputDir, platform),
})
} else {
// 无需解析,直接拷贝,如 quickapp-webview
projectJson = template
}
}
......
......@@ -141,6 +141,7 @@ const options = {
},
project: {
filename: projectConfigFilename,
config: ['project.wx.json', 'project.config.json'],
source,
},
template: Object.assign(Object.assign({}, miniProgram), { customElements, filter: {
......
......@@ -98,6 +98,7 @@ export const options: UniMiniProgramPluginOptions = {
},
project: {
filename: projectConfigFilename,
config: ['project.wx.json', 'project.config.json'],
source,
},
template: {
......
......@@ -105,6 +105,7 @@ ${filter.code}
},
project: {
filename: projectConfigFilename,
config: [],
source,
},
};
......
......@@ -69,6 +69,7 @@ ${filter.code}
},
project: {
filename: projectConfigFilename,
config: [],
source,
},
}
......@@ -8,7 +8,7 @@ importers:
'@dcloudio/uni-api': 3.0.0-alpha-3040120220308001
'@dcloudio/uni-app': 3.0.0-alpha-3040120220308001
'@jest/types': ^27.0.2
'@microsoft/api-extractor': ^7.19.2
'@microsoft/api-extractor': ^7.19.4
'@rollup/plugin-alias': ^3.1.1
'@rollup/plugin-babel': ^5.3.0
'@rollup/plugin-commonjs': ^17.0.0
......@@ -17,7 +17,7 @@ importers:
'@rollup/plugin-replace': ^2.3.4
'@rollup/plugin-strip': ^2.0.0
'@types/jest': ^26.0.23
'@typescript-eslint/parser': ^5.3.0
'@typescript-eslint/parser': ^5.14.0
'@vitejs/plugin-vue': ^2.2.4
'@vitejs/plugin-vue-jsx': ^1.3.8
'@vue/reactivity': 3.2.31
......@@ -55,7 +55,7 @@ importers:
'@dcloudio/uni-api': link:packages/uni-api
'@dcloudio/uni-app': link:packages/uni-app
'@jest/types': 27.4.2
'@microsoft/api-extractor': 7.19.2
'@microsoft/api-extractor': 7.19.4
'@rollup/plugin-alias': 3.1.8_rollup@2.60.2
'@rollup/plugin-babel': 5.3.0_rollup@2.60.2
'@rollup/plugin-commonjs': 17.1.0_rollup@2.60.2
......@@ -64,7 +64,7 @@ importers:
'@rollup/plugin-replace': 2.4.2_rollup@2.60.2
'@rollup/plugin-strip': 2.1.0_rollup@2.60.2
'@types/jest': 26.0.24
'@typescript-eslint/parser': 5.5.0_eslint@7.32.0+typescript@4.6.2
'@typescript-eslint/parser': 5.14.0_eslint@7.32.0+typescript@4.6.2
'@vitejs/plugin-vue': 2.2.4_vite@2.8.6+vue@3.2.31
'@vitejs/plugin-vue-jsx': 1.3.8
'@vue/reactivity': 3.2.31
......@@ -648,12 +648,11 @@ importers:
dependencies:
'@dcloudio/uni-cli-shared': link:../uni-cli-shared
'@dcloudio/uni-mp-compiler': link:../uni-mp-compiler
'@dcloudio/uni-mp-toutiao': link:../uni-mp-toutiao
'@dcloudio/uni-mp-vite': link:../uni-mp-vite
'@dcloudio/uni-mp-vue': link:../uni-mp-vue
'@dcloudio/uni-shared': link:../uni-shared
'@vue/compiler-core': 3.2.31
devDependencies:
'@dcloudio/uni-mp-toutiao': link:../uni-mp-toutiao
packages/uni-mp-qq:
specifiers:
......@@ -2823,24 +2822,24 @@ packages:
engines: {node: '>=4.2'}
dev: true
/@microsoft/api-extractor-model/7.15.1:
resolution: {integrity: sha512-DWfS1o3oMY0mzdO3OuQbD/9vzn80jwM6tFd7XbiYnkpxwhD83LMGXz7NZWwSh+IaA+9w3LF4w62fT31Qq+dAMw==}
/@microsoft/api-extractor-model/7.15.3:
resolution: {integrity: sha512-NkSjolmSI7NGvbdz0Y7kjQfdpD+j9E5CwXTxEyjDqxd10MI7GXV8DnAsQ57GFJcgHKgTjf2aUnYfMJ9w3aMicw==}
dependencies:
'@microsoft/tsdoc': 0.13.2
'@microsoft/tsdoc-config': 0.15.2
'@rushstack/node-core-library': 3.44.2
'@rushstack/node-core-library': 3.45.0
dev: true
/@microsoft/api-extractor/7.19.2:
resolution: {integrity: sha512-LxSa9lwp7eYtM4i5y/1n79QpotPKlmpCrVQbkb0LAHE1sCRHpZDTb6p3cMJthDhYPMjAYKOLfq639GwtZrg23Q==}
/@microsoft/api-extractor/7.19.4:
resolution: {integrity: sha512-iehC6YA3DGJvxTUaK7HUtQmP6hAQU07+Q/OR8TG4dVR6KpqCi9UPEVk8AgCvQkiK+6FbVEFQTx0qLuYk4EeuHg==}
hasBin: true
dependencies:
'@microsoft/api-extractor-model': 7.15.1
'@microsoft/api-extractor-model': 7.15.3
'@microsoft/tsdoc': 0.13.2
'@microsoft/tsdoc-config': 0.15.2
'@rushstack/node-core-library': 3.44.2
'@rushstack/rig-package': 0.3.6
'@rushstack/ts-command-line': 4.10.5
'@rushstack/node-core-library': 3.45.0
'@rushstack/rig-package': 0.3.7
'@rushstack/ts-command-line': 4.10.6
colors: 1.2.5
lodash: 4.17.21
resolve: 1.17.0
......@@ -2986,8 +2985,8 @@ packages:
estree-walker: 2.0.2
picomatch: 2.3.0
/@rushstack/node-core-library/3.44.2:
resolution: {integrity: sha512-lQ8Ct267UKkNSJSDxpBWn7SyyITWQ9l3Xqww0V+YY0rMt02r9eiGvwwPaU1ugJW7IMVo6r/HXvgbmpOSPyzGyg==}
/@rushstack/node-core-library/3.45.0:
resolution: {integrity: sha512-YMuIJl19vQT1+g/OU9mLY6T5ZBT9uDlmeXExDQACpGuxTJW+LHNbk/lRX+eCApQI2eLBlaL4U68r3kZlqwbdmw==}
dependencies:
'@types/node': 12.20.24
colors: 1.2.5
......@@ -3000,15 +2999,15 @@ packages:
z-schema: 5.0.2
dev: true
/@rushstack/rig-package/0.3.6:
resolution: {integrity: sha512-H/uFsAT6cD4JCYrlQXYMZg+wPVECByFoJLGqfGRiTwSS5ngQw9QxnFV2mPG2LrxFUsMjLQ2lsrYr523700XzfA==}
/@rushstack/rig-package/0.3.7:
resolution: {integrity: sha512-pzMsTSeTC8IiZ6EJLr53gGMvhT4oLWH+hxD7907cHyWuIUlEXFtu/2pK25vUQT13nKp5DJCWxXyYoGRk/h6rtA==}
dependencies:
resolve: 1.17.0
strip-json-comments: 3.1.1
dev: true
/@rushstack/ts-command-line/4.10.5:
resolution: {integrity: sha512-5fVlTDbKsJ5WyT6L7NrnOlLG3uoITKxoqTPP2j0QZEi95kPbVT4+VPZaXXDJtkrao9qrIyig8pLK9WABY1bb3w==}
/@rushstack/ts-command-line/4.10.6:
resolution: {integrity: sha512-Y3GkUag39sTIlukDg9mUp8MCHrrlJ27POrBNRQGc/uF+VVgX8M7zMzHch5zP6O1QVquWgD7Engdpn2piPYaS/g==}
dependencies:
'@types/argparse': 1.0.38
argparse: 1.0.10
......@@ -3339,8 +3338,8 @@ packages:
dev: true
optional: true
/@typescript-eslint/parser/5.5.0_eslint@7.32.0+typescript@4.6.2:
resolution: {integrity: sha512-JsXBU+kgQOAgzUn2jPrLA+Rd0Y1dswOlX3hp8MuRO1hQDs6xgHtbCXEiAu7bz5hyVURxbXcA2draasMbNqrhmg==}
/@typescript-eslint/parser/5.14.0_eslint@7.32.0+typescript@4.6.2:
resolution: {integrity: sha512-aHJN8/FuIy1Zvqk4U/gcO/fxeMKyoSv/rS46UXMXOJKVsLQ+iYPuXNbpbH7cBLcpSbmyyFbwrniLx5+kutu1pw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
......@@ -3349,9 +3348,9 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/scope-manager': 5.5.0
'@typescript-eslint/types': 5.5.0
'@typescript-eslint/typescript-estree': 5.5.0_typescript@4.6.2
'@typescript-eslint/scope-manager': 5.14.0
'@typescript-eslint/types': 5.14.0
'@typescript-eslint/typescript-estree': 5.14.0_typescript@4.6.2
debug: 4.3.3
eslint: 7.32.0
typescript: 4.6.2
......@@ -3359,21 +3358,21 @@ packages:
- supports-color
dev: true
/@typescript-eslint/scope-manager/5.5.0:
resolution: {integrity: sha512-0/r656RmRLo7CbN4Mdd+xZyPJ/fPCKhYdU6mnZx+8msAD8nJSP8EyCFkzbd6vNVZzZvWlMYrSNekqGrCBqFQhg==}
/@typescript-eslint/scope-manager/5.14.0:
resolution: {integrity: sha512-LazdcMlGnv+xUc5R4qIlqH0OWARyl2kaP8pVCS39qSL3Pd1F7mI10DbdXeARcE62sVQE4fHNvEqMWsypWO+yEw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.5.0
'@typescript-eslint/visitor-keys': 5.5.0
'@typescript-eslint/types': 5.14.0
'@typescript-eslint/visitor-keys': 5.14.0
dev: true
/@typescript-eslint/types/5.5.0:
resolution: {integrity: sha512-OaYTqkW3GnuHxqsxxJ6KypIKd5Uw7bFiQJZRyNi1jbMJnK3Hc/DR4KwB6KJj6PBRkJJoaNwzMNv9vtTk87JhOg==}
/@typescript-eslint/types/5.14.0:
resolution: {integrity: sha512-BR6Y9eE9360LNnW3eEUqAg6HxS9Q35kSIs4rp4vNHRdfg0s+/PgHgskvu5DFTM7G5VKAVjuyaN476LCPrdA7Mw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@typescript-eslint/typescript-estree/5.5.0_typescript@4.6.2:
resolution: {integrity: sha512-pVn8btYUiYrjonhMAO0yG8lm7RApzy2L4RC7Td/mC/qFkyf6vRbGyZozoA94+w6D2Y2GRqpMoCWcwx/EUOzyoQ==}
/@typescript-eslint/typescript-estree/5.14.0_typescript@4.6.2:
resolution: {integrity: sha512-QGnxvROrCVtLQ1724GLTHBTR0lZVu13izOp9njRvMkCBgWX26PKvmMP8k82nmXBRD3DQcFFq2oj3cKDwr0FaUA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
typescript: '*'
......@@ -3381,8 +3380,8 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/types': 5.5.0
'@typescript-eslint/visitor-keys': 5.5.0
'@typescript-eslint/types': 5.14.0
'@typescript-eslint/visitor-keys': 5.14.0
debug: 4.3.3
globby: 11.0.4
is-glob: 4.0.3
......@@ -3393,11 +3392,11 @@ packages:
- supports-color
dev: true
/@typescript-eslint/visitor-keys/5.5.0:
resolution: {integrity: sha512-4GzJ1kRtsWzHhdM40tv0ZKHNSbkDhF0Woi/TDwVJX6UICwJItvP7ZTXbjTkCdrors7ww0sYe0t+cIKDAJwZ7Kw==}
/@typescript-eslint/visitor-keys/5.14.0:
resolution: {integrity: sha512-yL0XxfzR94UEkjBqyymMLgCBdojzEuy/eim7N9/RIcTNxpJudAcqsU8eRyfzBbcEzGoPWfdM3AGak3cN08WOIw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
'@typescript-eslint/types': 5.5.0
'@typescript-eslint/types': 5.14.0
eslint-visitor-keys: 3.1.0
dev: true
......@@ -5625,7 +5624,6 @@ packages:
glob-parent: 5.1.2
merge2: 1.4.1
micromatch: 4.0.4
dev: false
/fast-glob/3.2.7:
resolution: {integrity: sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==}
......@@ -5636,6 +5634,7 @@ packages:
glob-parent: 5.1.2
merge2: 1.4.1
micromatch: 4.0.4
dev: false
/fast-json-stable-stringify/2.1.0:
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
......@@ -5936,7 +5935,7 @@ packages:
dependencies:
array-union: 2.1.0
dir-glob: 3.0.1
fast-glob: 3.2.7
fast-glob: 3.2.11
ignore: 5.1.9
merge2: 1.4.1
slash: 3.0.0
......@@ -8275,7 +8274,7 @@ packages:
/resolve/1.19.0:
resolution: {integrity: sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==}
dependencies:
is-core-module: 2.8.0
is-core-module: 2.8.1
path-parse: 1.0.7
dev: true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册