Skip to content

Webpack does not recognize new files (maybe batch file creation issue?) #18875

@Kokujou

Description

@Kokujou

Bug report

I have a typescript project, that i develop with VSCode.
In the workspace i have a task configured that automatically runs. this is webpack --watch.
there is no static entry file, rather I've used glob to simply tell webpack "bundle all TS" files, as it's a webcomponent project

my webpack config:

const path = require('path');
const { glob } = require('glob');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: glob
        .sync('./**/*.ts', { ignore: ['**/node_modules/**', '**/dist/**', '**/templates/**'] })
        .map((x) => './' + x), // Verwende glob, um alle .tsx-Dateien im src-Ordner zu finden
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: [
                    {
                        loader: 'ts-loader',
                        options: {
                            transpileOnly: true,
                        },
                    },
                ],
                exclude: [/node_modules/, /dist/],
            },
        ],
    },
    resolve: {
        extensions: ['.ts', '.js'],
        alias: {
            'lit/decorators': path.resolve(__dirname, './node_modules/lit/decorators.js'),
        },
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist'),
    },
    // plugins: [new LitAnalyzerPlugin()],
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html',
            filename: 'index.html',
        }),
        new webpack.HotModuleReplacementPlugin(),
    ],
    devServer: {
        static: {
            directory: path.join(__dirname, 'dist'),
        },
        hot: true,
    },
    devtool: 'source-map', // Fügt Source Maps hinzu
    watch: true,
};

What is the current behavior?

If i change any file that already exists, it works well. but if i create a new file, it doesn't detect that a new file is part of my solution. especially because customElements don't require imports in my scenario. this means now i need to restart webpack/my whole vscode to make it detect the changed files.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

webpack should detect that the entries have changed and simply load the additional dependencies.

Other relevant information:
webpack version: ^5.95.0
Node.js version: v20.14.0
Operating System: Windows 10
Additional tools: vscode + IIS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions