Allow custom cdn config
mastilver opened this issue ยท 4 comments
From #1 (comment) by @Van-Nguyen
Just the plugin I was looking for, I'm surprised it does not exist anywhere else yet. Nice work so far ๐
When a module is not found I'm getting this:
throw new Error(`'${moduleName}' is not available through cdn, add it to https://github.com/mastilver/module-to-cdn/blob/master/modules.json if you think it should`);
Would it be possible to add an option which can be additional to the modules.json
file, rather than needing to do a pull request every time it doesn't find it.
i.e.
new ModulesCdnWebpackPlugin({
additional: {
"vue": {
"var": "Vue",
"url": "https://unpkg.com/vue@[version]/dist/vue.runtime.min.js"
}
},
modules: ['vue']
})
This would make it much more flexible and less opinionated, what are your thoughts?
Cheers.
I would prefer this API:
new ModulesCdnWebpackPlugin({
modules: [
{
"var": "Vue",
"url": "https://unpkg.com/vue@[version]/dist/vue.runtime.min.js"
}
]
})
That way, in https://github.com/mastilver/modules-cdn-webpack-plugin/blob/master/src/index.js#L22
We can just do:
if (typeof name !== 'string) {
return name;
}
Nice one, much cleaner!
feel free to send a PR, there is no tests atm so don't bother with them, I will take care of that later
Or if you really want to, use ava
Sorry for coming back to you so late
Even if I say the contrary earlier, I don't thing it's a good idea
I want to keep this module API very minimal
If you want to add your modules, just send me a PR at: https://github.com/mastilver/module-to-cdn
With modules-cdn-webpack-plugin@2
you will be able to use a different one more easily, even if I don't recommend it
If you really want to use your own urls, you can still use: https://github.com/mmiller42/html-webpack-externals-plugin