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 / src / bundle / webpack.config.ts
Size: Mime:
/**
 * @file build a production output of all of our bundles.
 * @see dist/dist/bundled
 */
import { performance } from 'perf_hooks'
import { resolveToRoot } from '../resolveToRoot'
import config from '../oneConfig/getConfigForEnv'
import { webpackConfigFactory } from './webpackConfigFactory'

const start = performance.now()

// @note - this next require replaces `node scripts/shell/build_prod_pre &&`
// require('../.env').registerDotEnv()
try {
  require('../../shell/build_prod_pre')
} catch (exception) {
  console.warn('cannot copy package.json to dist')
  console.error(exception)
  console.log('^ do not worry')
}

delete process.env.LOG_BUILD_PROGRESS

// eslint-disable-next-line no-unused-vars
const [x, y, ...args] = process.argv
const optimize = process.env.OPTIMIZE
const ENV_INFRA = process.env.CI !== undefined
const IS_PRODUCTION = process.env.NODE_ENV === 'production'

const bundles = config('bundles')
const buildOutputPath = resolveToRoot(config('buildOutputPath'))
const bundleNames = Object.keys(bundles)

// [client, server]
const configs = bundleNames
  .map(bundleName => {
    const webpackConfig = 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'

    // so we can check the unminified output of server
    // if (bundleConfig.named === 'server') {
    //   bundleConfig.mode = 'development'
    // }

    return Object.assign({}, bundleConfig)
  })

// for checking just server
// .filter((value, index) => {
//   // if (index === 1) return true
//   if (index === 0) return true
//   return false
// })
// console.log(configs.length)
// throw new Error(configs.length)

const end = performance.now()
const diff = end - start
console.log('[bs]___end___', diff)

// require('fliplog').data(configs).bold('bundle configs:').echo()
export default configs