自定义组件资源文件打包方案(mendix 9.x有效)
engalar
2021.10.13 19:46发布于技术 - 前端与UI
440

步骤

  1. 在组件根目录添加文件rollup.config.js
    同容如下
import command from "rollup-plugin-command";
import { cp } from "shelljs";
import { join } from "path";


export default args => {
    const result = args.configDefaultConfig;
    let done = false;
    result.forEach(config => {
        const plugins = config.plugins || [];
        config.plugins = [
            done ? null : (done = true, command([() => {
                cp('-R', join(__dirname, `resources`), join(__dirname, `dist/tmp/widgets/resources`));
            }])),
            ...plugins
        ];
    });
    return result;
};
  1. 在组件根目录添加文件夹resources,把需要打包的资源文件放入其中即可

验证

http://localhost:8081/widgets/resources/lib/ui/index.html

示例

https://github.com/mendixCN/widgets-resources-cn/blob/306885f8ad34bb502640322a8d1537c49cdbb53b/packages/pluggableWidgets/fileviewer-web/rollup.config.js

Code_Dove
点赞
收藏
手机查看
举报
0个评论
倒序看帖
仅看楼主

暂无数据