-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't figure out a basic scenario working with my own CDN and packages #55
Comments
Same here, how do you set the urls to your own CDN? This module is not very useful if it only supports 1 CDN |
Hi, Sorry for the delay. It is indeed possible to use your own CDNs with this plugin. @shaipetel What error are you exactly getting with that config? The way you have provided a custom resolver looks correct to me. Can you pass @mgenev You can provide a custom resolver such as follows. const HtmlWebpackPlugin = require("html-webpack-plugin");
const DynamicCdnWebpackPlugin = require("dynamic-cdn-webpack-plugin");
module.exports = {
mode: "production",
plugins: [
new HtmlWebpackPlugin(),
new DynamicCdnWebpackPlugin({
resolver: (packageName, packageVersion, options) => {
let env = options.env || "development";
if (packageName === "react") {
return {
name: packageName,
var: "React",
version: packageVersion,
url: `https://cdn.jsdelivr.net/npm/${packageName}@${packageVersion}/umd/react.${env}.min.js`
};
} else {
return null;
}
}
})
]
}; Here I'm loading |
@shaipetel , on closer inspection, it looks like the module loaded from https://apps.kwizcom.com/libs/es6-promise/es6-promise.min.js attaches the promise to the window under Can you change your config to something like this resolver: function (packageName, version, params) {
switch (packageName) {
case "es6-promise":
return {
name: packageName,
var: "ES6Promise",
url: "https://apps.kwizcom.com/libs/es6-promise/es6-promise.min.js",
version: version
};
}
return null;
} |
thanks, looks like what I needed. I'll give it a try |
Basic scenario working with webpack and this package.
example:
main.ts
I'm hosting "es6-promise" under my own CDN: https://cdn.company.com/libs/es6-promise.js
I can't figure out how to make webpack not bundle es6-promise but instead load it from my CDN.
Better yet - I would ultimately would like to lazy-load it only when someone called GetDelayedMessage, if the code changes to this:
Could someone perhaps provide a basic webpack.config.js that covers this scenario?
I read through the documentation but can't find all the info regarding:
I tried to set up this plugin but that didn't work:
Thanks!!!
The text was updated successfully, but these errors were encountered: