V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
flyPig9527
V2EX  ›  程序员

webpack5 缓存文件过大的问题

  •  1
     
  •   flyPig9527 · 135 天前 · 675 次点击
    这是一个创建于 135 天前的主题,其中的信息可能已经有所发展或是发生改变。

    公司有个三年前的项目用的是 webpack 5.22.0 的版本,一天开发下来发现缓存文件 20 个 G 左右,就是这个文件node_modules\.cache\webpack
    有升级到 5.75.0 版本还是会这样,为什么?
    求大佬们给个解决方案。。。

    rules 配置

        oneOf: [
          {
            test: /\.(js|jsx|ts|tsx)$/,
            exclude: /node-modules/,
            loader: 'babel-loader',
            options: {
              // 开启 babel 缓存
              cacheDirectory: true
            }
          },
          {
            test: /\.(png|svg|jpg|jpeg|gif)$/,
            use: [
              {
                loader: 'url-loader',
                options: {
                  limit: 8192,
                  name: 'imgs/[name]_[hash:8][ext]',
                  fallback: 'file-loader?name=imgs/[name]_[hash:8][ext]'
                }
              }
            ]
          }
        ]
    

    babel 配置

    {
      "presets": [
        "@babel/preset-env",
        "@babel/preset-react",
        "@babel/preset-typescript"
      ],
      "plugins": [
        "@babel/plugin-syntax-dynamic-import",
        "@babel/plugin-transform-runtime",
        [
          "@babel/plugin-proposal-decorators",
          {
            "legacy": true
          }
        ],
        [
          "import",
          {
            "libraryName": "antd",
            "libraryDirectory": "lib",
            "style": true
          }
        ],
        [
          "@babel/plugin-proposal-class-properties",
          {
            "loose": true
          }
        ]
      ]
    }
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   900 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:20 · PVG 06:20 · LAX 15:20 · JFK 18:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.