简体   繁体   English

在 vuejs 中使用 CDN 是一个好习惯吗?

[英]using CDN in vuejs is a good practice?

I have a version issue using leaflet with leaflet-draw in vuejs.我在 vuejs 中使用带有传单绘制的 leaflet 有一个版本问题。 So I'm looking for alternatives for map function editing(add polylines, copy and paste functions, and more).所以我正在寻找 map function 编辑(添加折线、复制和粘贴功能等)的替代品。 I've found Korean specific one as I'm Korean, but it doesn't have any npm support.我找到了韩国特定的一个,因为我是韩国人,但它没有任何 npm 支持。 So I've asked around to Korean developers about using cdn in vusjs.因此,我向韩国开发人员询问了有关在 vusjs 中使用 cdn 的问题。 But no one couldn't answer it clearly as here in Korea we have a very small vuejs developer community.但是没有人能清楚地回答这个问题,因为在韩国我们有一个非常小的 vuejs 开发者社区。 It's really difficult to find the info even on the Internet.即使在互联网上也很难找到信息。

So what do you think?所以你怎么看? My senior says using CDN is not a good practice as we're using webpack to control all the modules but I really don't see 'why' I shouldn't use it.我的前辈说使用 CDN 不是一个好习惯,因为我们使用 webpack 来控制所有模块,但我真的不明白为什么我不应该使用它。

cdn based is useful for using the library without any compiler.基于 cdn 对于在没有任何编译器的情况下使用库很有用。 But you may not able to use feature such as lazy loading, es6 compatibility across browser, minification, etc. For long term development, I would suggest to use compiler like webpack.但是您可能无法使用延迟加载、跨浏览器的 es6 兼容性、缩小等功能。对于长期开发,我建议使用 webpack 之类的编译器。

modules can be import from cdn by webpack configuration.模块可以通过 webpack 配置从 cdn 导入。

// webpack.config.js
module.exports = {
  //...
  externals: {
    jquery: 'jQuery'
  }
};

check this out: https://webpack.js.org/configuration/externals/看看这个: https://webpack.js.org/configuration/externals/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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