webpack打包項目時typescript報錯The 'files' list in config file 'tsconfig.json' is empty.的解決方法


在用ts和react的項目中進行webpack編譯的時候,會出現如下報錯:

The 'files' list in config file 'tsconfig.json' is empty
Module build failed (from ../node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json

我的版本號如下:

"ts-loader": "^5.3.1",
"typescript": "^3.2.1",
"webpack": "^4.27.1"

經過查詢驗證,解決方案如下:

在ts-loader的配置項中指定ts配置文件的絕對路徑即可。

原代碼
module: { rules: [ { test:
/\.(tsx|ts)$/, loader: 'ts-loader' } ] }

修改后代碼
module: {
    rules: [
      {
        test: /\.(tsx|ts)$/,
        loader: 'ts-loader',
     options: {
configFile: path.resolve(__dirname, '../typescript.json')
     }
}
 ] }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM