webpack5中TypeScript报错,The 'files' list in config file 'tsconfig.json' is empty

1,321 阅读1分钟

背景

webpack5配置TypeScript报错,如下 The 'files' list in config file 'tsconfig.json' is empty

解决方案

问题是我在配置ts-loader 的时候,其中configFile配置路径出错了

正确如下:

{
    test: /\.(ts|tsx)$/,
    exclude: /node_modules/,
    use: [
        {
            loader: 'ts-loader',
            options: {
                // 指定特定的ts编译配置,为了区分脚本的ts配置
                configFile: path.resolve(__dirname, '../tsconfig.json'),
                appendTsSuffixTo: [/\.vue$/]
            }
        }
    ]
},