vite-plugin-cdn-import
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -110,2 +110,26 @@ import { Plugin } from 'vite'; | ||
}; | ||
axios: { | ||
var: string; | ||
jsdeliver: { | ||
path: string; | ||
}; | ||
}; | ||
lodash: { | ||
var: string; | ||
jsdeliver: { | ||
path: string; | ||
}; | ||
}; | ||
'crypto-js': { | ||
var: string; | ||
jsdeliver: { | ||
path: string; | ||
}; | ||
}; | ||
localforage: { | ||
var: string; | ||
jsdeliver: { | ||
path: string; | ||
}; | ||
}; | ||
}; | ||
@@ -112,0 +136,0 @@ declare type ModuleName = keyof typeof modulesConfig; |
@@ -119,2 +119,26 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty; | ||
} | ||
}, | ||
"axios": { | ||
var: "axios", | ||
jsdeliver: { | ||
path: "dist/axios.min.js" | ||
} | ||
}, | ||
"lodash": { | ||
var: "_", | ||
jsdeliver: { | ||
path: "lodash.min.js" | ||
} | ||
}, | ||
"crypto-js": { | ||
var: "crypto-js", | ||
jsdeliver: { | ||
path: "crypto-js.min.js" | ||
} | ||
}, | ||
"localforage": { | ||
var: "localforage", | ||
jsdeliver: { | ||
path: "dist/localforage.min.js" | ||
} | ||
} | ||
@@ -128,2 +152,5 @@ }; | ||
} | ||
function isCdnjs(prodUrl) { | ||
return prodUrl.includes("//cdnjs.cloudflare.com"); | ||
} | ||
function autoComplete(name) { | ||
@@ -135,3 +162,8 @@ const config = modulesConfig[name]; | ||
return (prodUrl) => { | ||
if (isJsdeliver(prodUrl) || isUnpkg(prodUrl)) { | ||
if (isCdnjs(prodUrl)) { | ||
throw new Error(`The configuration of module ${name} in ${prodUrl} does not exist `); | ||
} else { | ||
if (!(isJsdeliver(prodUrl) || isUnpkg(prodUrl))) { | ||
console.warn("Unknown prodUrl, using the jsdeliver rule"); | ||
} | ||
return __spreadValues({ | ||
@@ -141,4 +173,2 @@ name, | ||
}, config.jsdeliver); | ||
} else { | ||
throw new Error(`The configuration of module ${name} in ${prodUrl} does not exist `); | ||
} | ||
@@ -145,0 +175,0 @@ }; |
{ | ||
"name": "vite-plugin-cdn-import", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Import packages from CDN for the vite plugin", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -78,3 +78,9 @@ # Import modules from CDN with vite plugin | ||
``` | ||
"react" | "react-dom" | "react-router-dom" | "antd" | "ahooks" | "@ant-design/charts" | "vue" | "vue2" | "@vueuse/shared" | "@vueuse/core" | "moment" | "eventemitter3" | "file-saver" | "browser-md5-file" | "xlsx" | ||
"react" | "react-dom" | "react-router-dom" | | ||
"antd" | "ahooks" | "@ant-design/charts" | | ||
"vue" | "vue2" | "@vueuse/shared" | | ||
"@vueuse/core" | "moment" | | ||
"eventemitter3" | "file-saver" | | ||
"browser-md5-file" | "xlsx | "crypto-js" | | ||
"axios" | "lodash" | "localforage" | ||
``` | ||
@@ -81,0 +87,0 @@ |
@@ -76,3 +76,9 @@ # 从 CDN 加载 modules 的 vite 插件 | ||
``` | ||
"react" | "react-dom" | "react-router-dom" | "antd" | "ahooks" | "@ant-design/charts" | "vue" | "vue2" | "@vueuse/shared" | "@vueuse/core" | "moment" | "eventemitter3" | "file-saver" | "browser-md5-file" | "xlsx" | ||
"react" | "react-dom" | "react-router-dom" | | ||
"antd" | "ahooks" | "@ant-design/charts" | | ||
"vue" | "vue2" | "@vueuse/shared" | | ||
"@vueuse/core" | "moment" | | ||
"eventemitter3" | "file-saver" | | ||
"browser-md5-file" | "xlsx | "crypto-js" | | ||
"axios" | "lodash" | "localforage" | ||
``` | ||
@@ -79,0 +85,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26747
653
134