webpack 怎么打包一个 npm 包?可以让人 import 引入?
现在有这么个需求,但是我想用webpack来打包压缩代码。但是不知道怎么配置
webpack 怎么打包一个 npm 包?可以让人 import 引入?
现在有这么个需求,但是我想用webpack来打包压缩代码。但是不知道怎么配置
Rich Harris (the author of RollupJS) and I worked together to publish an article that explains when you should use Rollup vs webpack.
We released this article to inform folks that although webpack does support RollupJS features like "Scope Hoisting" in its latest stable versions (and that you can use the output.library
property to make a library with webpack), we recommend that you bundle your libraries with Rollup. The reasons why you can reference in the above article.
If you are using an app to consume one of these libraries, then webpack is a perfect option for your web app.
2 回答877 阅读✓ 已解决
2 回答920 阅读
1 回答953 阅读
1 回答764 阅读
820 阅读
587 阅读
设置
output
的libraryTarget
属性:意思是告诉webpack按照umd(AMD与CommonJS都可以使用)规范去打包。
可以看下具体的文档:
https://webpack.github.io/docs/configuration.html#output-librarytarget