0

I have multiple entry points in my webpack config and I want each entry point to bundle into its own folder with nothing

import path from 'path';
import webpack from 'webpack';
import TerserPlugin from 'terser-webpack-plugin';

// Entry files
const entries = {
  entry1: './src/entry/entry1.ts',
  entry2: './src/entry/entry2.ts',
  entry3: './src/entry/entry3.ts',
};

export default {
  mode: 'production',
  entry: entries,
  target: 'node',
  output: {
    filename: '[name]/index.js',
    path: path.resolve(process.cwd(), 'dist'),
    libraryTarget: 'commonjs2',
    clean: true, 
  },
  optimization: {
    splitChunks: false,
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          format: {
            comments: false,
          }
        },
        extractComments: false,
      })
    ]
  },
  resolve: {
    extensions: ['.ts', '.js'],
    extensionAlias: {
        '.js': ['.ts', '.js'],
        '.mjs': ['.mts', '.mjs'],
    },
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: {
          loader: 'ts-loader',
          options: {
            configFile: path.resolve('tsconfig.json'),
          },
        },
        exclude: /node_modules/,
      },
    ],
  },
  plugins: [
    new webpack.optimize.LimitChunkCountPlugin({
      maxChunks: 1,
    }),
  ],
};

I can't get it to not generate a folder with a chunk in addition to the entry folders. I want all the code to sit inside the entry files so they are standalone, how can I disable these chunks, I've tried a lot of different options with split chunks

1 Answer 1

2

Found the answer on github, to disable chunking pass chunkFormat:

Use the output section of the config, not the optimization section:


{
  output: {
    chunkFormat: false
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.