1 Star 0 Fork 5

daning/Evajs

forked from Gitee 极速下载/Evajs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rollup.miniprogram.plugin.js 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
fanmingfei 提交于 2021-11-24 17:15 . Feat/ali miniprogram (#156)
import inject from 'rollup-plugin-inject';
import modify from 'rollup-plugin-modify';
import fs from 'fs'
import path from 'path'
const packages = fs
.readdirSync(path.resolve(__dirname, 'packages'))
.filter(p => !p.endsWith('.ts') && !p.startsWith('.'));
const moduleName = '@eva/miniprogram-adapter';
function register(name) {
return [moduleName, name];
}
const adapterArray = {
window: 'windowAlias',
atob: 'atob',
devicePixelRatio: 'devicePixelRatio',
document: 'documentAlias',
Element: 'Element',
Event: 'Event',
EventTarget: 'EventTarget',
HTMLCanvasElement: 'HTMLCanvasElement',
HTMLElement: 'HTMLElement',
HTMLMediaElement: 'HTMLMediaElement',
HTMLVideoElement: 'HTMLVideoElement',
Image: 'Image',
navigator: 'navigator',
Node: 'Node',
requestAnimationFrame: 'requestAnimationFrame',
cancelAnimationFrame: 'cancelAnimationFrame',
screen: 'screen',
XMLHttpRequest: 'XMLHttpRequestAlias',
performance: 'performance',
HTMLImageElement: 'Image',
};
const adapterVars = {};
for (let name in adapterArray) {
adapterVars[name] = register(adapterArray[name]);
}
export const miniprogramPlugins1 = [
modify({
find: /@eva\/([\w\.\/-]*)/g,
replace: (match, moduleName) => {
if(moduleName === 'miniprogram-pixi' || moduleName === 'miniprogram-adapter') {
return `@eva/${moduleName}`;
}
if (moduleName.indexOf('/dist/miniprogram') > -1) {
return `@eva/${moduleName}`;
}
if (packages.indexOf(moduleName) > -1) {
return `@eva/${moduleName}/dist/miniprogram`;
}
return `@eva/${moduleName}`;
},
}),
modify({
find: /pixi\.js/g,
replace: `@eva/miniprogram-pixi`,
})
];
export const miniprogramPlugins2 = [
inject(adapterVars)
]
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/nyhxiaoning/Evajs.git
git@gitee.com:nyhxiaoning/Evajs.git
nyhxiaoning
Evajs
Evajs
dev

搜索帮助