【问题标题】:NextJs - next.config.js - CSS loader + custom Webpack configNextJs - next.config.js - CSS 加载器 + 自定义 Webpack 配置
【发布时间】:2018-12-17 03:26:46
【问题描述】:

我正在使用 NextJS,我正在尝试自定义我的配置。到目前为止,我已经尝试添加 CSS 支持 + 文件支持。

这里是我的 next.config.js :

const webpack = require("webpack");  
const withCSS = require('@zeit/next-css');


module.exports = withCSS({

  webpack : (config, { dev }) => {
    config.module.rules.push({
            test: [/\.svg$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
            loader: "file-loader",
            options: {
              name: "public/media/[name].[ext]",
              publicPath: url => url.replace(/public/, "")
            }
          });
    return config;
  } 
})

我的控制台返回我:

UnhandledPromiseRejectionWarning:错误:Chunk.entrypoints:使用 改为 Chunks.addGroup

我不知道是什么失败了。

如果有人有提示,那就太好了,

谢谢

【问题讨论】:

    标签: javascript reactjs webpack next.js


    【解决方案1】:

    您是否尝试过以其他方式包装它? 这可能有效(不是 100%):

    module.exports = (config, { dev }) =>{
    config.module.rules.push({
            test: [/\.svg$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
            loader: "file-loader",
            options: {
              name: "public/media/[name].[ext]",
              publicPath: url => url.replace(/public/, "")
            }
          });
    return withCss(config);
    

    } }

    还有一个 withImages 包装器,https://github.com/twopluszero/next-images

    const withImages = require('next-images') 
    module.exports = withImages(withCss())
    

    【讨论】:

      猜你喜欢
      • 2021-03-06
      • 2019-01-24
      • 2020-12-01
      • 1970-01-01
      • 2018-03-13
      • 2020-02-10
      • 2020-09-25
      • 2014-05-10
      • 1970-01-01
      相关资源
      最近更新 更多