├── .gitignore ├── .prettierrc ├── .eslintrc ├── src └── index.js ├── LICENSE ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.log 3 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "eslintIntegration": true, 3 | "singleQuote": true, 4 | "trailingComma": "es5" 5 | } 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb-base", "prettier"], 3 | "plugins": ["prettier"], 4 | "rules": { 5 | "prettier/prettier": "error", 6 | "no-param-reassign": 0 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); 2 | 3 | function rewireWebpackBundleAnalyzer(config, env, options = {}) { 4 | config.plugins = (config.plugins || []).concat([ 5 | new BundleAnalyzerPlugin(options), 6 | ]); 7 | 8 | return config; 9 | } 10 | 11 | module.exports = rewireWebpackBundleAnalyzer; 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ian Copp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-app-rewire-webpack-bundle-analyzer 2 | 3 | [![npm](https://img.shields.io/npm/v/react-app-rewire-webpack-bundle-analyzer.svg)](https://www.npmjs.com/package/react-app-rewire-webpack-bundle-analyzer) 4 | [![License](https://img.shields.io/npm/l/react-app-rewire-webpack-bundle-analyzer.svg)](https://github.com/byzyk/react-app-rewire-webpack-bundle-analyzer/blob/master/LICENSE) 5 | 6 | > Add [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer) to [`react-app-rewired`](https://github.com/timarney/react-app-rewired) config. 7 | 8 | ## Install 9 | 10 | ```sh 11 | npm install --save-dev react-app-rewire-webpack-bundle-analyzer 12 | ``` 13 | 14 | ## Usage 15 | 16 | ```js 17 | const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer') 18 | 19 | module.exports = function override(config, env) { 20 | // ... 21 | 22 | if (env === 'production') { 23 | config = rewireWebpackBundleAnalyzer(config, env, { 24 | analyzerMode: 'static', 25 | reportFilename: 'report.html' 26 | }) 27 | } 28 | 29 | return config 30 | } 31 | ``` 32 | 33 | ## License 34 | 35 | MIT © [Bohdan Khodakivskyi](https://bohdan-khodakivskyi.com) 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-app-rewire-webpack-bundle-analyzer", 3 | "version": "1.1.0", 4 | "description": "Add webpack-bundle-analyzer to a react-app-rewired config.", 5 | "main": "./src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/byzyk/react-app-rewire-webpack-bundle-analyzer.git" 12 | }, 13 | "keywords": [ 14 | "react", 15 | "react-app-rewired", 16 | "webpack-bundle-analyzer", 17 | "webpack" 18 | ], 19 | "author": "Bohdan Khodakivskyi (https://bohdan-khodakivskyi.com)", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/byzyk/react-app-rewire-webpack-bundle-analyzer/issues" 23 | }, 24 | "homepage": "https://github.com/byzyk/react-app-rewire-webpack-bundle-analyzer#readme", 25 | "dependencies": { 26 | "webpack-bundle-analyzer": "^3.4.1" 27 | }, 28 | "devDependencies": { 29 | "eslint": "^4.19.1", 30 | "eslint-config-airbnb-base": "^12.1.0", 31 | "eslint-config-prettier": "^2.9.0", 32 | "eslint-config-standard": "^11.0.0", 33 | "eslint-plugin-import": "^2.12.0", 34 | "eslint-plugin-node": "^6.0.1", 35 | "eslint-plugin-prettier": "^2.6.0", 36 | "eslint-plugin-promise": "^3.8.0", 37 | "eslint-plugin-standard": "^3.1.0", 38 | "prettier": "^1.13.4" 39 | } 40 | } 41 | --------------------------------------------------------------------------------