UNPKG

wx2

Version:

微信小程序 转换 百度小程序

20 lines (16 loc) 457 B
/** * @file 针对 相对路径进行转换 */ const {get, set, has} = require('lodash'); module.exports = function ({path, context, file}) { // 相对路径 const Reg = /^(\/|[a-z]+)[^:]/; const importPath = get(path, 'node.source.value'); if (!importPath) { return; } if (Reg.test(importPath)) { const filePath = `./${importPath}`.replace('//', '/'); set(path, 'node.source.value', filePath); } };