npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cmtlyt/plugin-use-container

v0.1.3

Published

将使用vite构建的项目运行在容器中

Downloads

37

Readme

@cmtlyt/plugin-use-container

将 vite 构建的应用运行在 web container 中, 同时提供后端支持

后端代码自行编写(可以使用 node api), 使用插件时, 传递后端代码路径和启动命令即可

注意: 这个后端代码, 运行时所有数据都是客户端的, 如果需要持久化, 则需要将数据同步至远程数据库

如果需要将运行时数据持久化到客户端, 可以使用 node:fs 模块将数据写入到 storage 目录下, 然后容器会自动保存这个目录下的文件进行客户端的持久化

import { writeFileSync, readFileSync } from 'fs';

readFileSync('storage/test.txt', { encoding: 'utf-8' }); // 第一次运行 找不到文件, 刷新页面后运行或写入后读取, 返回 'test'
writeFileSync('storage/test.txt', 'test');

更新日志

v0.1.3

自行实现 __dirname 和 __filename

v0.1.2

修改打包后文件后缀为 mjs

v0.1.1

修复 vite 设置 base 后导致资源类型错误问题

v0.1.0

提供 buildContainerPlugin / injectSourcePlugin 两个插件

buildContainerPlugin 用于将 vite 构建的应用运行在 web container 中, 并且可以通过配置打包后端文件, 如果传递了后端则运行时会发送一个 postMessage { type: 'backend-url', url: 'xxx' }, 在应用程序中可以通过监听 message 事件获取后端链接

injectSourcePlugin 用于将资源注入到 html 中, 例如全局变量等