Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
tinyjs-resource-loader
Advanced tools
用于处理 tinyjs 游戏资源的 webpack loader,旨在让 tinyjs 项目中的动画帧(雪碧图)合成流程更加符合 webpack 工作流
.tileset
(或任意名称)配置文件animation
├── .tileset
├── frame001.png
├── frame002.png
└── frame003.png
yaml
格式对 .tileset
进行配置skip: 1
colors: 16
webpack.config.js
中配置 tinyjs-resource-loader
,该 loader 应作用于上面的配置文件module.export = {
// statements
module: {
loaders: [
{
test: /\.tileset/i,
loader: 'tinyjs-resource-loader',
query: {
output: 'game/images',
image: { // 图片的 url-loader 参数
name: 'resources/[name].[ext]',
limit: 4096
},
json: { // JSON 的 url-loader 参数
name: 'resources/[name].[ext]',
limit: 1
}
}
}
]
},
output: {
path: path.resovle('dist')
}
};
.tileset
文件import tilesetAnimationJSON from './frames/animation/.tileset';
// 得到的是 JSON 文件的路径,并且 JSON 中图片的路径会自动根据 resources/[name].[ext] 配置项进行替换
skip
配置项来实现每 N 帧抽取一帧的功能colors
指定的颜色值进行压缩game/images
目录(由 query.output
指定)game
├── frames
│ ├── animation # 这里是动画帧存放的目录
│ │ ├── .tileset
│ │ ├── 001.png
│ │ ├── 002.png
│ │ └── 003.png
├── images # 图片处理后的 JSON 和图片存放目录
│ ├── tileset-animation.json
│ └── tileset-animation.png
└── resources.js
game/images
中的 JSON 和图片构建到 dist/resources
中(由 webpack config 中的 output.path
指定)dist
└── resources
├── tileset-animation.json
└── tileset-animation.png
在使用 tinyjs-resource-loader 处理 tinyjs 项目中的 JSON 和 png 之前,首先应确保系统中安装了以下工具:
identify
命令(主要用于获取一个或多个图像文件的格式和特性)pngquant
命令注意:如果系统中没有安装以上的依赖,构建时会跳过处理过程中的前 3 步,直接从
output
读取 JSON 和图片,并通过 url-loader 将它们构建到指定目录中,但会产生 webpack warning。这是为了确保项目在构建过一次以后,在 windows 环境或者远程机器也能够进行构建,兼顾跨平台或者云构建的需求
query.output
: 图片处理后输出 JSON 和图片文件的目录,一般选择源码中的目录,建议提交远程仓库query.image
:图片文件的 url-loader 参数query.json
:JSON 文件的 url-loader 参数trim
:移除图片周围的空白,参照 spritesheet.js,默认 false
padding
: 雪碧图中图片的间隙,参照 spritesheet.js,默认 10
skip
:抽帧时跳过的帧数,如果指定为 N,会每跳过 N 帧保留一帧,默认 0
colors
:雪碧图进行图片压缩的颜色数,默认 256
FAQs
用于处理 tiny.js 游戏资源的 webpack loader
The npm package tinyjs-resource-loader receives a total of 6 weekly downloads. As such, tinyjs-resource-loader popularity was classified as not popular.
We found that tinyjs-resource-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.