diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index c2f8cc813f3..f6b8fc86ed0 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -12,6 +12,7 @@ const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ManifestPlugin = require('webpack-manifest-plugin'); @@ -376,6 +377,11 @@ module.exports = { minifyURLs: true, }, }), + new DynamicCdnWebpackPlugin({ + only: ['react', 'react-dom'], + disable: false, // switch to true to disable + verbose: false, // switch to true to log which modules are being served from CDN + }), // Makes some environment variables available to the JS code, for example: // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`. // It is absolutely essential that NODE_ENV was set to production here. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 7fa42331eff..906f1e2f5f0 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -34,6 +34,7 @@ "css-loader": "0.28.9", "dotenv": "4.0.0", "dotenv-expand": "4.0.1", + "dynamic-cdn-webpack-plugin": "^3.4.1", "eslint": "4.15.0", "eslint-config-react-app": "^2.1.0", "eslint-loader": "1.9.0", @@ -47,6 +48,7 @@ "html-webpack-plugin": "2.30.1", "identity-obj-proxy": "3.0.0", "jest": "22.1.2", + "module-to-cdn": "^3.1.1", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.10",