4 changed files with 48 additions and 9 deletions
-
8src/subpackage/groupon/pages/confirm_order/ticket.vue
-
5src/subpackage/groupon/pages/list.vue
-
27tools/generate-package-plugin.js
-
17vite.config.js
@ -0,0 +1,27 @@ |
|||
import path from 'path'; |
|||
import fs from 'fs'; |
|||
|
|||
/** |
|||
* 在构建完成后自动生成 package.json 文件 配置行业 SDK。 |
|||
* |
|||
* @param {string} outputDir - 输出目录,通常是构建平台对应的输出路径(如 dist/dev/mp-toutiao) |
|||
* @param {object} packageContent - 要写入 package.json 的内容对象 |
|||
* @returns {object} - 一个符合 Vite 插件规范的插件对象 |
|||
*/ |
|||
function generatePackageJsonPlugin(outputDir, packageContent) { |
|||
return { |
|||
name: 'custom-generate-package-json', |
|||
apply: 'build', |
|||
generateBundle() { |
|||
const outputPackageJsonPath = path.resolve(outputDir, 'package.json'); |
|||
try { |
|||
fs.mkdirSync(path.dirname(outputPackageJsonPath), { recursive: true }); |
|||
fs.writeFileSync(outputPackageJsonPath, JSON.stringify(packageContent, null, 2), 'utf-8'); |
|||
} catch (error) { |
|||
console.error('[package.json] Failed to generate:', error); |
|||
} |
|||
}, |
|||
}; |
|||
} |
|||
|
|||
module.exports = { generatePackageJsonPlugin }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue