/* eslint-disable no-param-reassign, global-require */

module.exports = baseConfig => {
  baseConfig.module.rules.push({
    test: /\.css$/,
    use: [
      {
        loader: 'style-loader',
      },
      {
        loader: 'css-loader',
        options: {
          modules: true,
          localIdentName: '[name]-[local]_[hash:base64:5]',
          importLoaders: 1,
        },
      },
      {
        loader: 'postcss-loader',
        options: {
          plugins: [require('../src/theme')({ appendVariables: true })],
        },
      },
    ],
  });

  return baseConfig;
};

/* eslint-disable no-param-reassign, global-require */

module.exports = baseConfig => {
  // Replace storybook baseConfig rule.
  baseConfig.module.rules.splice(0, 1, {
    test: /\.js$/,
    exclude: /node_modules/,
    use: [
      {
        loader: 'babel-loader',
        options: {
          presets: ['./babel.config.js'],
        },
      },
    ],
  });

  baseConfig.module.rules.push({
    test: /\.css$/,
    use: [
      {
        loader: 'style-loader',
      },
      {
        loader: 'css-loader',
        options: {
          modules: true,
          localIdentName: '[name]-[local]_[hash:base64:5]',
          importLoaders: 1,
        },
      },
      {
        loader: 'postcss-loader',
        options: {
          plugins: [require('../src/theme')({ appendVariables: true })],
        },
      },
    ],
  });

  return baseConfig;
};

Make Storybook work with babel 7
Make Storybook work with babel 7
