简体   繁体   中英

LibMan without internet prevents build. Is there a local fallback option?

I have an aspnet core project (dotnet core 2.2). It uses the Microsoft.Web.LibraryManager.Build (1.0.172) package. If the network is down, the build fails with a bunch of similar errors:

Error LIB002 The "toastr.js@2.1.4" library could not be resolved by the "cdnjs" provider C.Web.App C:\\Users\\bburns\\code\\C.WEB.APP\\libman.json 1

libman.json looks like

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "jquery@3.3.1",
      "destination": "wwwroot/lib/jquery"
    },

    ...

Is there a way to specify an offline fallback when cdnjs is unavailable?

You can save the libs in a local or shared location and reference that in your projects, as in this example of the documentation :

{
  "provider": "filesystem",
  "library": "C:\\temp\\lodash\\",
  "files": [
    "lodash.js",
    "lodash.min.js"
  ],

Where library may be a relative path as well.

The drawback is that updates are not detected from the project, so you'll have to think of a strategy on how to keep the libraries up-to-date.

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