1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| const { whenProd, getPlugin, pluginByName } = require('@craco/craco')
const path = require('path') module.exports = { webpack: { alias: { '@': path.resolve(__dirname, 'src'), }, configure: (webpackConfig) => { webpackConfig.externals = whenProd( () => ({ react: 'React', 'react-dom': 'ReactDOM', redux: 'Redux', 'react-router-dom': 'ReactRouterDOM', }), {} ) const { isFound, match } = getPlugin( webpackConfig, pluginByName('HtmlWebpackPlugin') ) if (isFound) { match.options.cdn = { js: whenProd( () => [ 'https://cdn.bootcdn.net/ajax/libs/react/18.2.0/cjs/react-jsx-dev-runtime.production.min.js', 'https://cdn.bootcdn.net/ajax/libs/react-dom/18.2.0/cjs/react-dom-server-legacy.browser.production.min.js', 'https://cdn.bootcdn.net/ajax/libs/redux/4.2.1/redux.min.js', 'https://cdn.bootcdn.net/ajax/libs/react-router-dom/6.10.0/react-router-dom.production.min.js', ], [] ), css: [], } } return webpackConfig }, }, }
|