{"size": 1119, "ext": "js", "max_stars_repo_path": ".storybook/webpack.config.js", "max_stars_repo_name": "yeojz/react-unhook", "max_stars_repo_stars_event_min_datetime": "2019-04-02T00:04:28.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-02T00:04:28.000Z", "max_issues_repo_path": ".storybook/webpack.config.js", "max_issues_repo_name": "yeojz/react-unhook", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": ".storybook/webpack.config.js", "max_forks_repo_name": "yeojz/react-unhook", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.3260869565, "max_line_length": 77, "alphanum_fraction": 0.6050044683}
const path = require('path');
const { compilerOptions } = require('../tsconfig.json');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const ROOT_DIR = path.join(__dirname, '..');
const SOURCE = path.join(ROOT_DIR, 'src');
const STORIES = path.join(ROOT_DIR, 'stories');

module.exports = function({ config }) {
  config.module.rules.push({
    test: /\.story\.tsx?$/,
    loaders: [
      {
        loader: require.resolve('@storybook/addon-storysource/loader'),
        options: { parser: 'typescript' }
      }
    ],
    enforce: 'pre'
  });

  config.module.rules.push({
    test: /\.tsx?$/,
    loader: 'ts-loader',
    include: [SOURCE, STORIES],
    options: {
      transpileOnly: true, // use transpileOnly mode to speed-up compilation
      compilerOptions: {
        ...compilerOptions,
        declaration: false,
        rootDir: ROOT_DIR
      }
    }
  });

  config.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx'];
  config.plugins.push(
    new ForkTsCheckerWebpackPlugin({
      compilerOptions: {
        rootDir: ROOT_DIR
      }
    })
  );

  return config;
};
