UNPKG

@megalo/entry

Version:

解析配置在 `main.js` 或者 `App.vue` 中的 [小程序全局配置](https://developers.weixin.qq.com/miniprogram/dev/framework/config.html#%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AE)并生成webpack所需要的entry键值对

28 lines (24 loc) 658 B
const babelon = require('babelon') const generate = require('babel-generator').default module.exports = function ({ types: t }) { return { visitor: { ExportDefaultDeclaration (path) { path.node.declaration.properties.forEach(prop => { if ( t.isObjectProperty(prop) && t.isIdentifier(prop.key, { name: 'config' }) ) { const code = generate(prop.value).code path.hub.file.metadata.config = { code: code, node: prop.value, value: babelon.eval(code) } } }) path.remove() } } } }