我想从requirejs迁移到webpack,而在requirejs配置中,我有:
paths: {
'jquery.ui.core': 'lib/jquery.ui/jquery.ui.core-1.11.4',
'jquery.ui.draggable': 'lib/jquery.ui/jquery.ui.draggable-1.11.4',
'jquery.ui.mouse': 'lib/jquery.ui/jquery.ui.mouse-1.11.4',
'jquery.ui.widget': 'lib/jquery.ui/jquery.ui.widget-1.11.4',
...
shim: {
'jquery.ui.mouse': ['jquery.ui.core', 'jquery.ui.widget'],
....jquery.ui.core和jquery.ui.widget是jquery.ui.mouse的依赖项。如何使webpack将这些模块作为jquery.ui.mouse的依赖项加载?
webpack在shim配置属性中的依赖项选择是什么?
发布于 2015-08-18 18:41:30
需要为shim:https://github.com/webpack/imports-loader使用"imports-loader“
loaders: [..., {
// if use npm module 'jquery-ui' instead of 'lib/...' directory in question
include: require.resolve('jquery-ui/ui/mouse'),
loader: "imports-loader?dep1=jquery.ui.core&dep2=jquery.ui.widget"
}, ...]对于path,应该使用resolve.alias
resolve: {
...
alias: {
'jquery.ui.core': 'jquery-ui/ui/core',
'jquery.ui.draggable': 'jquery-ui/ui/draggable',
'jquery.ui.droppable': 'jquery-ui/ui/droppable',
'jquery.ui.mouse': 'jquery-ui/ui/mouse',
'jquery.ui.sortable': 'jquery-ui/ui/sortable',
'jquery.ui.widget': 'jquery-ui/ui/widget',
...
}
...
}https://stackoverflow.com/questions/31922888
复制相似问题