我正在尝试让Webpack设置与isotope.js一起使用。我遇到的问题是,当webpack进行编译时,它找不到窗口并抛出错误。
尝试了以下内容:
在myfile.js中import Isotope from 'isotope-layout';
webpack.config.jsloaders: [{ test: /isotope-layout/, loader: 'imports?this=>window!isotope-layout' }
但它引发以下错误:
/ipb/node_modules/lodash/index.js" as it exceeds the max of "100KB".
/Users/user/Development/ipb/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:206
throw e;
^
ReferenceError: window is not defined
at Object.<anonymous> (/Users/user/Development/ipb/node_modules/isotope-layout/js/isotope.js:60:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at DependenciesBlock.loadPitch (/Users/user/Development/ipb/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:193:17)
at DependenciesBlock.loadPitch (/Users/user/Development/ipb/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:186:21)
at DependenciesBlock.loadPitch (/Users/user/Development/ipb/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:223:61)
我在这里做错了什么,或者什么是实现此目标的更好方法?
最佳答案
尝试一些
var Isotope = require('imports?$=jquery!isotope-layout/dist/isotope.pkgd');
这似乎对我有用。请注意,此解决方案取决于imports-loader;
您可以将其推送到Webpack配置,而不是内联解决。只是希望这个答案可以为您指明正确的方向。
关于javascript - Isotope.js和Webpack-可能吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31077156/