qlin f8b70f0ebb Ts type (#133)
* fix: 优化类型提示

* fix: 添加 enums 接口类型声明

* feat: 配置插件api提示

Co-authored-by: wanchun <445436867@qq.com>
2022-06-22 19:24:49 +08:00

50 lines
1.1 KiB
JavaScript

import { join } from 'path';
import { name } from '../package.json';
const namespace = 'plugin-watermark';
export default (api) => {
api.describe({
key: 'watermark',
config: {
schema(joi) {
return joi.object({
disabled: joi.boolean(),
});
},
default: {},
},
});
const absoluteFilePath = join(namespace, 'core.js');
// 当配置为disabled时不显示水印
api.modifyConfig((memo) => {
const defineConfig = memo.define;
defineConfig.WATERMARK_DISABLED = memo.watermark.disabled ?? false;
return {
...memo,
define: defineConfig,
};
});
api.onGenerateFiles(() => {
api.copyTmpFiles({
namespace,
path: join(__dirname, 'runtime'),
ignore: ['.tpl'],
});
});
api.addPluginExports(() => [
{
specifiers: ['createWatermark', 'destroyWatermark'],
source: absoluteFilePath,
},
]);
api.addConfigType(() => ({
source: name,
}));
};