Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Command Line Interface for MIP 2.0.
Prerequisites: Node.js (>=8.x), npm version 3+ and Git.
$ npm install -g mip2
创建项目
$ mip2 init
新增一个组件
在项目根目录运行 mip2 add
命令,即可快速添加一个新组件
# 快速添加名为 mip-new 的组件
$ mip2 add mip-new
# 使用 -f 或 --force 参数强制覆盖同名组件
$ mip2 add mip-new -f
启动调试服务器,在项目根目录运行
$ mip2 dev
Example:
# 可使用 ——port 指定端口
$ mip2 dev --port 8888
组件和页面校验
集成到 cli 工具中的校验分为三种:
$ mip2 validate
Example:
# 组件校验
$ mip2 validate components
$ mip2 validate -c components
# 页面校验
$ mip2 validate -p page.html
# npm 白名单校验
$ mip2 validate -w path-to-project
构建组件,在项目根目录运行
$ mip2 build
生成 Service Worker
mip2 CLI 提供了 sw
命令,帮助开发者更简单快速地生成 Service Worker,支持离线可用等特性。
# 在项目根目录运行
$ mip2 sw
默认情况下,将导出 Service Worker 文件到 dist/sw.js
,并对静态资源(如 js,css)及 html 文档进行缓存,实现页面的离线可用。
mip2 sw
命令提供了选项:
-o, --output // 指定 sw 导出路径,如 mip2 -o output/service-worker.js
-c, --config // 指定配置文件路径,默认使用项目根目录 mip.config.js
除此之外,我们可以在 mip.config.js
中增加 serviceWorker
配置项,对 Service Worker 进行进一步的配置,如预缓存列表、动态缓存策略、skipWaiting
、clientsClaim
等。
module.exports = {
dev: {/*...*/},
serviceWorker: {
cacheId: 'mipuser',
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [],
globPatterns: [],
globIgnores: []
}
}
更多的配置选项可以参考 Workbox 配置项
本地启动 SF 调试环境
$ mip2 sf
运行命令后,会在本地启动一个服务器,可以通过 http://localhost:8210/sf
进行访问,对页面嵌入 SF 的情况进行调试和验证。
详情可以查看插件项目仓库 mip-cli-plugin-sf
FAQs
CLI for mip 2.0
The npm package mip2 receives a total of 53 weekly downloads. As such, mip2 popularity was classified as not popular.
We found that mip2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.