我尝试使用 NPM 和 Webpack 进行捆绑,将 Open Layers 3 导入到我的应用程序中,但我收到错误并且 map 未渲染:
./~/openlayers/dist/ol.js Critical dependencies: 567:411-418 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results. @ ./~/openlayers/dist/ol.js 567:411-418
使用以下方式导入开放层:
import ol from 'openlayers';
我尝试在 Webpack 中使用 noParse
选项: noParse:/dist\/ol.js/
但没有成功。
如何将 Open Layers 与 NPM 和 Webpack 结合使用?
最佳答案
显然我必须准确地找到它所在的位置:
工作解决方案:
var Path = require("path");
noParse: [Path.join(__dirname, "node_modules/openlayers/dist/ol.js")]
关于javascript - 使用 NPM 和 Webpack 的开放层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38241698/