webpack 怎么打包一个 npm 包?可以让人 import 引入?

webpack 怎么打包一个 npm 包?可以让人 import 引入?
现在有这么个需求,但是我想用webpack来打包压缩代码。但是不知道怎么配置

阅读 5.8k
2 个回答

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.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题