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 / build.js
Size: Mime:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * @file build a production output of all of our bundles.
 * @see dist/dist/bundled
 */
require("./setup");
const webpack_1 = __importDefault(require("webpack"));
const getConfigForEnv_1 = require("../../config/oneConfig/getConfigForEnv");
const utils_1 = require("../utils");
const webpackConfigFactory_1 = require("./webpackConfigFactory");
function bundle() {
    const optimize = process.env.OPTIMIZE !== undefined;
    const ENV_INFRA = process.env.CI !== undefined;
    const bundles = getConfigForEnv_1.getConfig('bundles');
    const buildOutputPath = process.env.BUNDLE_SERVER_OUTPUT_PATH_ABSOLUTE;
    const bundleNames = Object.keys(bundles);
    utils_1.deleteDist(buildOutputPath);
    const configs = bundleNames
        .map((bundleName) => {
        const webpackConfig = webpackConfigFactory_1.webpackConfigFactory({
            target: bundleName,
            optimize,
        });
        // webpack validates all keys, this will make it hidden
        Object.defineProperty(webpackConfig, 'named', {
            enumerable: false,
            value: bundleName,
        });
        return webpackConfig;
    })
        .map((bundleConfig) => {
        bundleConfig.watch = false;
        /**
         * @todo this works in webpack 4.5...
         * @see https://webpack.js.org/concepts/mode
         * @todo @fixme @perf @prod !!!!!!! THIS IS DISABLED BECAUSE THE TREE SHAKING IS MAKING SOME EXPORTS UNDEFINED
         */
        bundleConfig.mode = 'none';
        // bundleConfig.mode = 'production'
        // bundleConfig.mode = 'development'
        return Object.assign({}, bundleConfig);
    });
    // require('fliplog').data(configs).bold('bundle configs:').echo()
    const compiler = webpack_1.default(configs);
    // # @todo load argv into dotenv
    // # --optimize
    // # --optimize-occurrence-order
    // # --optimize-minimize
    // # --profile
    // # --verbose
    // # --display-reasons
    // # --display-error-details
    // # --display-modules
    // # --display-exclude
    // # --display-chunks
    // # --display=verbose
    // # --progres
    console.log('begining the build...');
    compiler.run((compilationError, stats) => {
        if (compilationError) {
            throw compilationError;
        }
        if (ENV_INFRA) {
            console.log('minimal logs for CI');
        }
        else {
            const json = stats.toJson({
                reasons: true,
                errors: true,
                modules: true,
                exclude: true,
                chunks: true,
                verbose: true,
                debug: true,
                providedExports: false,
                usedExports: true,
                maxModules: 1000,
            });
            require('fliplog')
                .json(json)
                .bold('STATS')
                .echo();
            console.log(stats.toString({ colors: true }));
            require('../shell/build_prod_post');
        }
    });
}
exports.bundle = bundle;
//# sourceMappingURL=build.js.map