diff --git a/package.json b/package.json index a8e428dbe1..08728d235d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "babel-core": "^7.0.0-bridge.0" }, "scripts": { - "analyze": "yarn run build && yarn source-map-explorer packages/apps/build/main.*.js", + "analyze": "yarn clean && BUILD_ANALYZE=1 yarn run build:code && yarn source-map-explorer packages/apps/build/main.*.js", "build": "yarn run build:i18n && yarn run build:code", "build:code": "NODE_ENV=production node_modules/@polkadot/dev/scripts/polkadot-dev-build-ts.js", "build:i18n": "i18next-scanner --config i18next-scanner.config.js && node ./scripts/i18nSort.js", diff --git a/packages/apps/webpack.base.config.js b/packages/apps/webpack.base.config.js index 1215560325..5d42d55a4e 100644 --- a/packages/apps/webpack.base.config.js +++ b/packages/apps/webpack.base.config.js @@ -123,23 +123,41 @@ function createWebpack (ENV, context) { runtimeChunk: 'single', splitChunks: { cacheGroups: { - polkadotJs: { + polkadotJsLibs: { chunks: 'initial', enforce: true, - name: 'polkadotjs', + name: 'polkadotjs.libs', test: /node_modules\/@polkadot\/(api|api-derive|extension-dapp|keyring|metadata|react-identicon|react-qr|rpc-core|rpc-provider|types|ui-keyring|ui-settings|ui-shared|util|util-crypto|vanitygen|wasm-crypto)/ }, - vendorOther: { + reactIcons: { chunks: 'initial', enforce: true, - name: 'vendor', - test: /node_modules\/(asn1|bn\.js|buffer|cuint|elliptic|lodash|moment|readable-stream|rxjs|secp256k1|webrtc-adapter|remark-parse)/ + name: 'other.icons', + test: /node_modules\/(@fortawesome)/ }, - vendorReact: { + reactLibs: { chunks: 'initial', enforce: true, - name: 'react', - test: /node_modules\/(@semantic-ui-react|chart|i18next|jidenticon|qrcode-generator|react|react-dom|semantic-ui-css|semantic-ui-react|styled-components)/ + name: 'other.react', + test: /node_modules\/(react|react-dom|styled-components)/ + }, + reactUI: { + chunks: 'initial', + enforce: true, + name: 'other.components', + test: /node_modules\/(@semantic-ui-react|chart\.js|codeflask|copy-to-clipboard|jdenticon|qrcode-generator|react-i18next|react-qr-reader|semantic-ui-react|semantic-ui-css)/ + }, + vendorGeneral: { + chunks: 'initial', + enforce: true, + name: 'other.general', + test: /node_modules\/(@ledgerhq|bn\.js|buffer|core-js|cuint|i18next|lodash|moment|readable-stream|remark-parse|rtcpeerconnection-shim|rxjs|webrtc-adapter)/ + }, + vendorHashing: { + chunks: 'initial', + enforce: true, + name: 'other.hashing', + test: /node_modules\/(asn1|base-x|base64-js|blakejs|bip39|bip66|browserify-aes|browserify-cipher|browserify-des|browserify-rsa|browserify-sign|cipher-base|create-ecdh|create-hash|create-hmac|crypto-browserify|des\.js|diffie-hellman|elliptic|hash|hmac-drbg|js-sha3|md5|miller-rabin|minimalistic-crypto-utils|parse-asn1|pbkdf2|public-encrypt|randombytes|randomfill|ripemd160|secp256k1|sha\.js|xxhashjs)/ } } } diff --git a/packages/apps/webpack.config.js b/packages/apps/webpack.config.js index 79aac65d44..f31f22bbe1 100644 --- a/packages/apps/webpack.config.js +++ b/packages/apps/webpack.config.js @@ -10,15 +10,14 @@ const merge = require('webpack-merge'); const baseConfig = require('./webpack.base.config'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const ENV = process.env.NODE_ENV || 'development'; const context = __dirname; const hasPublic = fs.existsSync(path.join(context, 'public')); -const ENV = process.env.NODE_ENV || 'development'; - module.exports = merge( baseConfig(ENV, context), { - devtool: false, + devtool: process.env.BUILD_ANALYZE ? 'source-map' : false, plugins: [ new HtmlWebpackPlugin({ PAGE_TITLE: 'Polkadot/Substrate Portal',