modules-cdn-webpack-plugin
Dynamically get your dependencies from a cdn rather than bundling them in your app
Install
$ npm install --save modules-cdn-webpack-plugin module-to-cdn
Usage with HtmlWebpackPlugin
webpack.config.js
const path = ; const HtmlWebpackPlugin = ;const ModulesCdnWebpackPlugin = ; moduleexports = entry: 'app.js': './src/app.js' output: path plugins:
app.js
;; // ... do react stuff
NODE_ENV=production webpack
will generate:
/* simplified webpack build */ { moduleexports = React;}) { moduleexports = ReactRouterDOM;} { var react = ; var reactRouterDOM = ; /* ... */}
Webpack App
Usage with ManifestPlugin
webpack.config.js
const path = ; const ManifestPlugin = ;const ModulesCdnWebpackPlugin = ; moduleexports = entry: 'app': './src/app.js' output: path plugins: fileName: 'manifest.json'
app.js
;; // ... do react stuff
NODE_ENV=production webpack
will generate:
/* simplified webpack build */ { moduleexports = React;}) { moduleexports = ReactRouterDOM;} { var react = ; var reactRouterDOM = ; /* ... */}
API
ModulesCdnWebpackPlugin(options)
options.disable
Type: boolean
Default: false
Usefull when working offline, will fallbacl to webpack normal behaviour
options.env
Type: string
Default: process.env.NODE_ENV || 'development'
Values: development
, production
Determine if it should load the development or the production version of modules
options.only
Type: Array<string>
Default: null
List the only modules that should be served by the cdn
options.exclude
Type: Array<string>
Default: []
List the modules that will always be bundled (not be served by the cdn)
options.verbose
Type: boolean
Default: false
Log whether the library is being served by the cdn or is bundled
Related
Contributors
Thanks goes to these wonderful people (emoji key):
Thomas Sileghem 💻 📖 ⚠️ |
MICHAEL JACKSON 💡 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
License
MIT © Thomas Sileghem