Webpack equivalent for browserify shiming(global) of already included modules

有些话、适合烂在心里 提交于 2019-12-24 14:13:51

问题


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

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.

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

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


回答1:


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

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


来源:https://stackoverflow.com/questions/33731430/webpack-equivalent-for-browserify-shimingglobal-of-already-included-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!