我不知道为什么,但是我的 webpack 配置创建了非常大的应用程序构建(15MB 单个app.js
文件)
有什么办法可以让这个文件变小吗?
我正在建立生产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"
我不擅长 webpack 配置,所以也许你可以告诉我应该更改或添加什么?这是最新的反应应用程序。