const antdTheme = require("./antd-theme");
const path = require("path");

module.exports = {
  module: {
    rules: [
      {
        exclude: (modulePath) => {
          return (
            /node_modules/.test(modulePath) && !/node_modules[\\/]react-draggable/.test(modulePath)
          );
        },
        test: /\.jsx?$/,
        loader: "babel-loader",
        options: {
          configFile: path.resolve(__dirname, "../.babelrc"),
        },
      },
      {
        include: /[\\/]node_modules[\\/].*antd/,
        test: /\.less$/,
        loader: [
          "style-loader",
          "css-loader",
          {
            loader: "less-loader",
            options: {
              modifyVars: antdTheme,
              javascriptEnabled: true,
            },
          },
        ],
      },
      {
        exclude: /node_modules/,
        test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|webm)(\?.*$|$)/i,
        use: [
          {
            loader: "file-loader",
            options: {
              name: "assets/[name].[ext]",
            },
          },
        ],
      },
    ],
  },
  resolve: {
    modules: [
      path.resolve(__dirname, "../../../node_modules"),
      "node_modules",
      path.resolve(__dirname, "../src/components"),
    ],
    alias: {
      react: require.resolve("react"),
      "react-dom": require.resolve("react-dom"),
    },
  },
};
