Webpack等效于已经包含的模块的browserify shiming(global) [英] Webpack equivalent for browserify shiming(global) of already included modules

查看:72
本文介绍了Webpack等效于已经包含的模块的browserify shiming(global)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是等效于browserify shiming的webpack?

I am wondering what the webpack equivalent of browserify shiming is?

我使用npm和webpack开发了一个小部件,该小部件包含在另一个应用程序中。

I develop a widget using npm and webpack which is included in another app. This other app already includes moment.js already in a script tag.

我不想在小部件包中再次捆绑moment.js,但仍然可以使用它。 (<时刻开始导入时间为)。

I don't want to bundle moment.js again in the widget bundle but still be able to use it. (import moment from 'moment').

在浏览器中,这是通过 global:moment 语句完成的。有人知道webpack等效吗?

In browserify this was done with a global:moment statement. Does someone know the webpack equivalent?

推荐答案

我知道了。我将以下内容放入我的 webpack.config.js

I figured it out. I put the following in my webpack.config.js:

externals: {
  'moment': 'moment',
},

这篇关于Webpack等效于已经包含的模块的browserify shiming(global)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆