title: Ignore .d.ts files for Webpack/Babel?
body: <p>I'm using <code>@teamsupercell/typings-for-css-modules-loader</code> to generate TS types for my SASS modules. The output looks something like:</p>
  
  <pre><code>declare namespace LoginRouteStylesScssModule {
    export interface ILoginRouteStylesScss {
      card: string;
      emailForm: string;
      info: string;
      input: string;
    }
  }
  
  declare const LoginRouteStylesScssModule: LoginRouteStylesScssModule.ILoginRouteStylesScss &amp; {
    /** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
    locals: LoginRouteStylesScssModule.ILoginRouteStylesScss;
  };
  
  export = LoginRouteStylesScssModule;
  </code></pre>
  
  <p>This lets it pass <code>tsc</code>. However, Babel is telling me <code>'export =' is not supported by @babel/plugin-transform-typescript. Please consider using 'export &lt;value&gt;;'.</code> I want to just ignore <code>.d.ts</code> files since they're intended for <code>tsc</code> and not Webpack/Babel.</p>
  
  <p>I tried <code>exclude</code> in <code>.babelrc</code>, <code>exclude</code> and <code>ignore</code> in <code>webpack.config.js</code>, and <code>webpack.IgnorePlugin</code>, but none of them work. How can I configure either Webpack or Babel to ignore them?</p>
  
  <p>`webpack.config.js':</p>
  
  <pre><code>const path = require('path');
  const childProcess = require('child_process');
  const webpack = require('webpack');
  
  const APP_ROOT = path.resolve('./src');
  
  module.exports = {
    entry: {
      index: path.resolve('./src/main.tsx'),
    },
    output: {
      path: path.resolve('./public/js'),
      publicPath: '/js/',
    },
    module: {
      rules: [
        {
          test: /\.(j|t)sx?$/,
          include: [APP_ROOT],
          exclude: [path.resolve('./node_modules')],
          use: {
            loader: 'babel-loader',
            options: {},
          },
        },
        {
          test: /\.s?css$/,
          include: [APP_ROOT],
          exclude: [/node_modules/],
          use: [
            '@teamsupercell/typings-for-css-modules-loader',
            {
              loader: 'css-loader',
              options: {
                importLoaders: 1,
                modules: {
                  localIdentName: '[name]__[local]',
                },
              },
            },
            'postcss-loader',
            'sass-loader',
            {
              loader: 'sass-resources-loader',
              options: {
                resources: [
                  path.resolve('./src/styles/imports/variables.scss'),
                  path.resolve('./src/styles/imports/mixins.scss'),
                ],
              },
            },
          ],
        },
        {
          test: /\.png$/,
          use: [
            'file-loader?name=../css/sprites/[name].png',
          ],
        },
      ],
    },
    resolve: {
      modules: [APP_ROOT, path.resolve('./node_modules')],
      extensions: ['.js', '.jsx', '.ts', '.tsx'],
      alias: {
        sprites: path.resolve('./public/css/sprites'),
      },
    },
    optimization: {},
    context: APP_ROOT,
    plugins: [
      new webpack.optimize.ModuleConcatenationPlugin(),
      new webpack.DefinePlugin({
        MODULE_CONFIG: null,
      }),
      new webpack.EnvironmentPlugin({
        NODE_ENV_ACTUAL: process.env.NODE_ENV || null,
        API_URL: process.env.API_URL || null,
        ASSETS_URL: process.env.ASSETS_URL || null,
        JS_VERSION: parseInt(
          (childProcess.execSync('git rev-list --count master').toString()).trim(),
          10,
        ),
      }),
    ],
    cache: true,
    devtool: false,
    watchOptions: {
      ignored: [
        path.resolve('./public'),
        path.resolve('./src/styles/generated/**'),
        path.resolve('./src/**/*.d.ts'),
      ],
    },
  };
  </code></pre>
  
  <p><code>babel.config.js</code>:</p>
  
  <pre><code>module.exports = {
    presets: [
      ['@babel/preset-env', {
        useBuiltIns: 'usage',
        corejs: '3',
        exclude: [
          'babel-plugin-transform-async-to-generator',
          'babel-plugin-transform-regenerator',
        ],
      }],
      '@babel/preset-typescript',
    ],
    plugins: [
      '@babel/plugin-syntax-dynamic-import',
      ['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
      '@babel/plugin-proposal-do-expressions',
      '@babel/plugin-proposal-class-properties',
      '@babel/plugin-proposal-optional-chaining',
      /* Async/await increases file size by a lot.
      ["module:fast-async", {
        "compiler": { "promises": true, "generators": false, "useRuntimeModule": true },
      }],
      ["@babel/plugin-transform-modules-commonjs", {
        "strictMode": false,
      }], */
    ],
    env: {
      production: {
        plugins: ['transform-react-remove-prop-types'],
      },
    },
  };
  </code></pre>