Webpack adding node module js files to my dist folder

Viewed 249

I believe Webpack should only be creating main.js and main.css according to my config. For a long time in the development of this project, that's all it did. But recently, it's started adding more things.

My dist folder now contains:

_2259.js
index.html
main.css
main.js
node_modules_express_lib_sync_recursive.js
node_process-node_stream_web.js
vendors-node_modules_deepai_index_js.js
vendors-node_modules_express_index_js.js
vendors-node_modules_node-fetch_src_index_js.js

So that's 6 unexpected files, apparently related to the node modules I am using in my project.

Can anyone help pinpoint what went wrong here?

Here's webpack.config.js:

// webpack.config.js

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const config = {
  entry: [
    path.resolve(__dirname, 'src', 'index.js'),
    path.resolve(__dirname, 'src', 'index.scss'),
  ],
  output: {
    path: path.join(__dirname, 'dist'), // bundled file in dist/
    filename: '[name].js',
  },
  module: {
    rules: [
      {
        test: /\.js$/, // applies to js files
        use: ['babel-loader'], // transpiles your js
        exclude: /node_modules/, // don't transpile node modules
      },
      {
        test: /\.s?[ac]ss$/, // applies to css/scss/sass files
        use: [
          MiniCssExtractPlugin.loader, // create bundled css file
          {
            loader: 'css-loader', // resolves @import statements
            options: { url: false } // don't resolve url() statements
          },
          'sass-loader', // compiles sass to css
        ]
      }
    ],
  },
  resolve: {
    fallback: {
      "buffer": false,
      "fs": false,
      "tls": false,
      "net": false,
      "path": false,
      "zlib": false,
      "http": false,
      "https": false,
      "stream": false,
      "crypto": false,
      "querystring": false,
      "os": false,
      "string_decoder": false,
      "util": false,
      "url": false,
    }
  },
  plugins: [new MiniCssExtractPlugin()],
  // devtool: 'source-map',
};

module.exports = (env, argv) => {
  target: 'node'
  if (argv.mode === 'production') {
    config.devtool = 'source-map';
  } else {
    config.devtool = 'eval-source-map';
  }
  return config;
}
0 Answers
Related