I don't know why but my webpack config creates very large application build (15MB single app.js
file)
Is there anything I can do to make this file smaller?
I am builing production with yarn build-production
// package.json
"scripts": {
"clean": "rimraf dist/*",
"build-production": "webpack --progress --bail --env production -p",
"build-app": "webpack --progress --bail -p",
"start": "webpack --progress --env prepare-localhost && webpack-dev-server --hot --open --watch"
},
// webpack.conf.js
'use strict';
/* eslint no-console: "off" */
const configFactory = require('./config/webpack');
const defaultConfig = 'dev';
module.exports = (configName) => {
// If there was no configuration give, assume default
const requestedConfig = configName || defaultConfig;
let loadedInstance = null;
try {
loadedInstance = configFactory(configName);
} catch(exception) {
console.warn('Probably config is missing, used dev as default. Please try: production, localhost, test, prepare-localhost... Exception: ' + exception.message);
loadedInstance = configFactory(defaultConfig);
}
// Set the global environment
process.env.NODE_ENV = loadedInstance.env;
return loadedInstance.config;
};
// package.json
"webpack": "^3.5.6",
"webpack-cli": "^2.0.11",
"webpack-dev-server": "^2.7.1"
I'm not good with webpack configuration so maybe you could tell me what should I change or add? This is latest react app.