const path = require("path");
const ProgressBarPlugin = require("progress-bar-webpack-plugin");

module.exports = {
  resolve: {
    extensions: [".js", ".jsx", ".ts", ".tsx", ".json"]
  },
  plugins: [new ProgressBarPlugin()],
  module: {
    rules: [
      {
        test: /\.[jt]sx?$/,
        include: [
          path.resolve(__dirname, "src"),
          path.resolve(__dirname, "styleguide")
        ],
        use: [
          {
            loader: "babel-loader",
            options: {
              presets: [["buildo", { env: "react" }]]
            }
          },
          {
            loader: "ts-loader",
            options: {
              configFile: require("path").resolve(__dirname, "tsconfig.json")
            }
          }
        ]
      },
      {
        test: /\.css$/,
        loader: [
          "style-loader",
          { loader: "css-loader", options: { modules: true } }
        ]
      },
      {
        test: /\.scss$/,
        use: ["style-loader", "css-loader", "sass-loader"]
      },
      {
        test: /\.(png|jpg|gif)$/,
        loader: "file-loader",
        options: {
          name: "[name].[ext]"
        }
      }
    ]
  }
};
