问题
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