您好,我正在尝试将一个RequireJS应用程序迁移到Webpack。我所有的js文件都包含在项目中,我没有使用任何来自node_modules的东西。为什么它要尝试从那里包含?这是一个仅在web浏览器中使用的web项目,不使用browserify。
这是我的webpack.config.js:
module.exports = {
resolve: {
modules: [
'private/application/controllers/'
],
alias: {
typeahead: 'system/js/jquery.typeahead.min',
bloodhound: 'system/js/bloodhound.min',
...
}
},
module: {
loaders: [
{ test: /typeahead/, loader: 'imports-loader?jquery' },
{ test: /bloodhound/, loader: 'imports-loader?typeahead' },
...
]
},
plugins: [
new webpack.IgnorePlugin( /^\.\/locale$/, /moment$/ )
],
target: 'web',
entry: {
app: 'system/js/app',
module: 'system/js/module',
...
},
output: {
libraryTarget: 'amd',
filename: '[name].min.js',
path: __dirname + 'public/files/cache'
}
};我得到的错误是:
ERROR in ./node_modules/timers-browserify/main.js
Module not found: Error: Can't resolve 'setimmediate' in '/Users/name/Sites/revamp/node_modules/timers-browserify'
@ ./node_modules/timers-browserify/main.js 51:0-23
@ ./private/application/controllers/system/js/jquery.typeahead.min.js谢谢!
发布于 2017-09-07 17:07:01
我想你的加载器会在整个项目文件夹中搜索这些文件。您可以尝试将exclude: /node_modules/添加到每个加载器。
module: {
loaders: [
{ test: /typeahead/, loader: 'imports-loader?jquery', exclude: /node_modules/ },
{ test: /bloodhound/, loader: 'imports-loader?typeahead', exclude: /node_modules/ },
...
]
},https://stackoverflow.com/questions/46077874
复制相似问题