Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/bs / dist / scripts / bundle / analyze.js
Size: Mime:
"use strict";
/**
 * This script creates a webpack stats file on our production build of the
 * client bundle and then launches the webpack-bundle-analyzer tool allowing
 * you to easily see what is being included within your bundle.
 *
 * @see https://github.com/th0r/webpack-bundle-analyzer
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const fs_1 = require("fs");
const webpack_1 = __importDefault(require("webpack"));
const di_1 = require("@skava/di");
const utils_1 = require("../utils");
const getConfigForEnv_1 = __importDefault(require("../../config/oneConfig/getConfigForEnv"));
const webpackConfigFactory_1 = require("./webpackConfigFactory");
const appRootDir = di_1.config.get('appRootDir');
// eslint-disable-next-line no-unused-vars
const [x, y, ...args] = process.argv;
const analyzeServer = args.findIndex(arg => arg === '--server') !== -1;
const analyzeClient = args.findIndex(arg => arg === '--client') !== -1;
const clientOutputPath = getConfigForEnv_1.default('bundles.client.outputPath');
let target;
if (analyzeServer) {
    target = 'server';
}
else if (analyzeClient) {
    target = 'client';
}
else {
    throw new Error('Please specify --server OR --client as target');
}
const anaylzeFilePath = path_1.resolve(appRootDir, clientOutputPath, '__analyze__.json');
const clientConfig = webpackConfigFactory_1.webpackConfigFactory({ target, optimize: true });
const clientCompiler = webpack_1.default(clientConfig);
clientCompiler.run((compilationError, stats) => {
    if (compilationError) {
        console.error(compilationError);
    }
    else {
        // Write out the json stats file.
        fs_1.writeFileSync(anaylzeFilePath, JSON.stringify(stats.toJson('detailed'), undefined, 4));
        // Run the bundle analyzer against the stats file.
        const cmd = `webpack-bundle-analyzer ${anaylzeFilePath} ${clientOutputPath}`;
        utils_1.exec(cmd);
    }
});
//# sourceMappingURL=analyze.js.map