简体   繁体   中英

Open Layers with NPM and Webpack

I'm trying to import Open Layers 3 into my application using NPM and Webpack for bundling, but I am receiving the error and the map not rendering:

./~/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

Importing Open Layers using:

import ol from 'openlayers';

I've tried to use the noParse option in in Webpack: noParse: /dist\\/ol.js/ with no luck.

How to use Open Layers with NPM and Webpack?

Apperently I had to locate it exactly where it was:

Working solution:

var Path = require("path");
noParse: [Path.join(__dirname, "node_modules/openlayers/dist/ol.js")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM