简体   繁体   English

Browserify:从节点模块中获取缩小的文件

[英]Browserify: take minified file from node module

I installed bootstrap via npm and i'd like to require it via browserify, so I use: 我通过npm安装了bootstrap,我想通过browserify要求它,所以我使用:

require('bootstrap');

But there are 2 problems here: 但是这里有两个问题:

  1. It takes the non minified version of bootstrap 它需要引导程序的非缩小版本
  2. I would also like to include the bootstrap.tpl.min file 我也想包含bootstrap.tpl.min文件

How can i do it? 我该怎么做?

Unfortunately browserify won't solve either of those problems for you. 不幸的是,bro​​wserify无法为您解决任何一个问题。 NPM packages are meant to be small and solve one problem well and browserify's domain is resolving all the dependencies you require and packaging them up into one file for the browser. NPM软件包的尺寸很小,可以很好地解决一个问题,而browserify的领域正在解决您所需的所有依赖关系,并将其打包为一个浏览器文件。

Minification of your bundle should happen as part of your build step using gulp or grunt using a package like uglify . 捆绑软件的微小应该发生,因为使用的构建步骤的一部分一饮而尽咕噜使用包像丑化

Including a template file will also require some additional work if it's not included in what's exported from bootstrap. 如果从引导程序导出的内容中未包含模板文件,则还需要一些额外的工作。 You can either require the specific file from the module if you need access to it in code, or you could copy it to the directory that you're serving up either with your build tool or using bower 如果需要通过代码访问特定文件,则可以从模块中获取特定文件,也可以将其复制到使用构建工具或Bower服务的目录中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM