const packageJson = require('./package.json')
const version = packageJson.version.split('.').join('_')
const namespace = `core-${version}`

if (process.env.BUNDLING) {
  module.exports = {
    ignore: [/(.*)\.(coverage|stories|test|snap)\.?(.*)?/],
    presets: [
      ['@babel/preset-env', { modules: false }],
      '@babel/preset-react',
      '@babel/preset-typescript',
    ],
    plugins: [
      '@babel/plugin-proposal-object-rest-spread',
      [
        'babel-plugin-styled-components',
        {
          displayName: true,
          fileName: false,
          minify: true,
          namespace,
          pure: true,
          transpileTemplateLiterals: true,
        },
      ],
    ],
  }
} else {
  module.exports = {
    presets: [
      '@babel/preset-env',
      '@babel/preset-react',
      '@babel/preset-typescript',
    ],
    plugins: ['@babel/plugin-proposal-object-rest-spread'],
  }
}
