仅 npm 安装缩小版 [英] npm install minified version only
问题描述
我刚刚使用 npm 安装了 Node,以将其用于前端依赖项管理.我知道还有 bower 但为什么我需要另一个构建在另一个之上的包管理器?
I just installed Node with npm to use it for frontend dependency management. I know there is also bower but why would I need another package manager that is built on top of another?
安装包时,npm 似乎总是将 js 库的完整源代码加载到 node_modules
目录中.就像它正在下载完整的 github 存储库一样.
When installing a package, npm seems to always load the full source of the js library into the node_modules
directory. Just as it's downloading the complete github repository.
如何只安装带有 npm 的 javascript 库的小型(分发)版本?
How do I install only the minifed (distribution) version of a javascript lib with npm?
推荐答案
没有标准的方法可以让 npm
获得库的缩小版本.一些开发人员会生成包含缩小版和未缩小版的包(这就是我为我的一个项目所做的,该项目仅限网络,但可以通过 npm
安装) 或将创建一个包含未缩小版本的包和另一个包含缩小版本的包.这是逐案完成的,因包而异,必须通过查看项目文档来确定.
There is no standard way to ask npm
to get the minified version of a library. Some developers will produce packages that contain both minified and unminified versions (that's what I've done for one of my projects, which is web-only but can be installed through npm
) or will create a package that contains an unminified version and another package that contains the minified version. This is done on a case by case basis, varies from package to package, and has to be determined by looking at a project's documentation.
如果开发人员不关心通过 npm
提供缩小的代码库,那么您必须自己执行缩小或通过其他方式获得官方"缩小的代码.
If a developer has not cared to provide a minified code base through npm
then you'll have to perform the minification yourself or get the "official" minified code through some other means.
这篇关于仅 npm 安装缩小版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!