Sha256: 5d849c8277d207a10d66b3c7fa656ac301986cb431d8941edd3f58f979216be5

Contents?: true

Size: 1.67 KB

Versions: 6

Compression:

Stored size: 1.67 KB

Contents

const { moduleExists } = require('@rails/webpacker')

module.exports = function config(api) {
  const validEnv = ['development', 'test', 'production']
  const currentEnv = api.env()
  const isDevelopmentEnv = api.env('development')
  const isProductionEnv = api.env('production')
  const isTestEnv = api.env('test')

  if (!validEnv.includes(currentEnv)) {
    throw new Error(
      `Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(
        currentEnv
      )}".`
    )
  }

  return {
    presets: [
      isTestEnv && ['@babel/preset-env', { targets: { node: 'current' } }],
      (isProductionEnv || isDevelopmentEnv) && [
        '@babel/preset-env',
        {
          useBuiltIns: 'entry',
          corejs: '3.8',
          modules: 'auto',
          bugfixes: true,
          loose: true,
          exclude: ['transform-typeof-symbol']
        }
      ],
      moduleExists('@babel/preset-typescript') && [
        '@babel/preset-typescript',
        { allExtensions: true, isTSX: true }
      ],
      moduleExists('@babel/preset-react') && [
        '@babel/preset-react',
        {
          development: isDevelopmentEnv || isTestEnv,
          useBuiltIns: true
        }
      ]
    ].filter(Boolean),
    plugins: [
      ['@babel/plugin-proposal-class-properties', { loose: true }],
      ['@babel/plugin-transform-runtime', { helpers: false }],
      isProductionEnv &&
        moduleExists('babel-plugin-transform-react-remove-prop-types') && [
          'babel-plugin-transform-react-remove-prop-types',
          { removeImport: true }
        ]
    ].filter(Boolean)
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
webpacker-6.0.0.rc.6 package/babel/preset.js
webpacker-6.0.0.rc.5 package/babel/preset.js
webpacker-6.0.0.rc.4 package/babel/preset.js
webpacker-6.0.0.rc.3 package/babel/preset.js
webpacker-6.0.0.rc.2 package/babel/preset.js
webpacker-6.0.0.rc.1 package/babel/preset.js