构建自己的cube.js playground

cube.js 的playground 是可以修改的(开源,自定义),但是因为有依赖,所以很多时候直接使用是不行的

解决方法

  • 使用npm 的shrinkwrap进行依赖的改写
  • 使用yarn 具体与npm 类似
  • 自己编译一个版本,使用私服进行替换
  • 自己编译playground 添加一个自己的静态website

参考实践

我比较推荐的方法是自己构建playground 然后基于cube.js 提供的扩展点进行静态资源的提供,以下是参考使用

  • 构建playground
    clone代码然后结合自己的要求修改playground的代码,然后进行构建(构建难度不大,就是普通的web构建)
  • 基于cube.js 的扩展改写一个静态playground 的入口
    需要依赖serve-static (参考了官方代码)
    index.js
 
const serveStatic = require('serve-static');
const path = require("path")
module.exports = function (app) {
   // 自定义的playground,位置在cube app 的playground 目录
    app.use(serveStatic(path.join(__dirname, './playground'), {
        lastModified: false,
        etag: false,
        setHeaders: (res, url) => {
            if (url.indexOf('/index.html') !== -1) {
                res.setHeader('Cache-Control', 'no-cache');
            }
        }
    }));
}

cube.js

// Cube.js configuration options: https://cube.dev/docs/config
const index = require("./index")
 
module.exports = {
    initApp:index
};
  • 运行效果

 

 

playgrpound 构建几个问题

playground 构建可能会有几个问题(less版本问题,rollup 版本问题)

参考资料

https://cube.dev/docs/@cubejs-backend-server
https://docs.npmjs.com/cli/v7/commands/npm-shrinkwrap
https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
https://stackoverflow.com/questions/40226639/how-do-i-override-nested-dependencies-with-yarn/41082766#41082766
https://nodejs.org/en/blog/npm/managing-node-js-dependencies-with-shrinkwrap/
https://www.cnblogs.com/rongfengliang/p/14691321.html

posted on   荣锋亮  阅读(213)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-05-09 CloudBeaver 参考架构
2018-05-09 ffmpeg hls 点播负载均衡简单实现
2018-05-09 nginx grpc 试用
2018-05-09 autoconf 添加三方库(libcurl)简单试用
2015-05-09 nodejs 任务调度使用
2014-05-09 SQL Server MERGE
2014-05-09 ORA-01791: not a SELECTed expression

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示