1

I'm using the original create-react-app to build, without eject. But I find the build result is very large, it is 2MB, is it normal? I removed 'window.REDUX_DEVTOOLS_EXTENSION_COMPOSE', actually, I didn't use it, at all.

import { createStore, compose, applyMiddleware } from 'redux'
import reducer from './reducer'
import thunk from 'redux-thunk'

// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;//reduxTool
const composeEnhancers = compose;

const store = createStore(reducer, composeEnhancers(
  applyMiddleware(thunk)
))

export default store

package.json

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Here's the build result screenshot.

Serg
  • 2,346
  • 3
  • 29
  • 38
Nicole
  • 127
  • 1
  • 1
  • 7
  • 1
    Does this answer your question? [Javascript .map files - javascript source maps](https://stackoverflow.com/questions/21719562/javascript-map-files-javascript-source-maps) – Emile Bergeron Apr 30 '20 at 06:36

1 Answers1

3

The file you've pointed to is the source map file.

This is not your minified production code (which is the other file). The source map file is used to map the minified code back to a uncompiled/minified/built state for debugging, so you'd expect its size to be larger. See here for more details: https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

This is normal for CRA.

If you want to disable the production of a source map, see here: How to generate sourcemaps in create react app?

RowanC
  • 1,611
  • 10
  • 16
  • In the link of html5rocks, Ryan said "The source map file will only be downloaded if you have source maps enabled and your dev tools open. You'll also need to upload your original files so the dev tools can reference and display them when necessary." So, does it mean, only when my dev tools open, the navigator will send request to my web server to download the source map file? My common end user won't need to download the source map file, right...? – Nicole Apr 30 '20 at 08:06
  • 1
    @Mahatini yes exactly. The only reason to remove source map from the production build would be to obfuscate your implementation a little. – Emile Bergeron Apr 30 '20 at 17:41