title: webpack style, ts and css loader should only build files inside current folder
body: <p>My issue is that I have a webpack project where I include typescript classes / types / css files and resources outside the &quot;src dir&quot; of the project. So basically only files within the &quot;src&quot; folder should be included, no files outside that directory or even higher in file hierarchy.</p>
  <p><a href="https://i.stack.imgur.com/ppSaW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ppSaW.png" alt="enter image description here" /></a></p>
  <p>These files outside the project dir should not be included in the built, since they are already existing on runtime.
  As far as I understood this can achieve by using the resolve function.</p>
  <pre><code>include: path.resolve(__dirname, 'src')
  </code></pre>
  <p>That only results in the error &quot;ReferenceError: path is not defined&quot;. I don't know where I would define it actually.</p>
  <p>I think this is a rather simple question, but I seem not to find the solution to it.
  I am using webpack 4.44.1 and webpack-cli 3.3.12 .</p>
  <pre><code>const {CleanWebpackPlugin} = require('clean-webpack-plugin');
  const path = require(&quot;path&quot;)
  module.exports = {
      optimization: {
          minimize: false
      },
      entry: {
          'code': './src/code.ts'
      },
      plugins: [
          new CleanWebpackPlugin({
              cleanAfterEveryBuildPatterns: ['public/build']
          }),
      ],
      output: {
          path: __dirname + '/public',
          //filename: 'build/[name].[contenthash].js',
          filename: 'build/[name].js',
      },
      module: {
          rules: [
              {
                  test: /\.ts?$/, use: 'ts-loader', exclude: /node_modules/
              },
              {
                  test: /\.css$/i,
                  use: ['style-loader', 'css-loader'],
              },
              {
                  test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2|json|xml|ico|cur|ani)$/,
                  use: ['file-loader?name=[path][name].[ext]']
              },
          ]
      },
      resolve: {
          extensions: [
              '.ts',
              '.js',
              '.json',
          ],
      },
  };
  </code></pre>