[英]Webpack modules dependencies like in requirejs
I want to migrate from requirejs to webpack and in requirejs config I have: 我想从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
and jquery.ui.widget
are dependencies of jquery.ui.mouse
. jquery.ui.core
和jquery.ui.widget
是jquery.ui.widget
的依赖jquery.ui.mouse
。 How to make webpack load this modules as dependencies of jquery.ui.mouse
? 如何使webpack将此模块作为
jquery.ui.mouse
依赖项jquery.ui.mouse
?
What webpack's alternative of dependencies in shim
config property ? shim
config属性中有哪些webpack替代依赖项?
Need to use "imports-loader" for shim
: https://github.com/webpack/imports-loader 需要对
shim
使用“ imports-loader”: https : //github.com/webpack/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"
}, ...]
And for path
should use resolve.alias
对于
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',
...
}
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.