Closed M69W closed 8 months ago
First vite-plugin-cdn2
is not a perfect solution but it can convert most of scenes. The follow error message means you should check the right relativeModule
for them.(perhaps they don't have unpkg
or jsdelivr
filed to scanner or it's not a javascript file to scan.)
The network error seems like the error resolve caused :)
First
vite-plugin-cdn2
is not a perfect solution but it can convert most of scenes. The follow error message means you should check the rightrelativeModule
for them.(perhaps they don't haveunpkg
orjsdelivr
filed to scanner or it's not a javascript file to scan.) The network error seems like the error resolve caused :)
Thanks a lot. The plugin would be export the name
by modules when custom setting ?
some dependencies by installed and existed.
return cdn({
modules: [
{
name: "axios",
aliasName: "axios.min.js"
},
"normalize.css",
"nprogress",
"vconsole"
],
resolve: {
name: "resolve:custom",
setup({ extra }) {
const { name, relativeModule, version } = extra;
let url = "";
if (name) {// here the name by modules setting be custom setting
const baseURL = "https://cdn-anc.com";
url = new URL(`${name}`, baseURL);
}
console.log("url", url);
return {
url: url.href,
injectTo: "head-prepend",
attrs: {}
};
}
}
});
@M69W Yeah, everything should lived in your local environment
demo https://github.com/yulimchen/vue3-h5-template
package.json
cdn.js