最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - NextJs - next.config.js - CSS loader + custom Webpack config - Stack Overflow

programmeradmin1浏览0评论

I'm working with NextJS and I'm trying to custom my configuration. So far, I have tried to add CSS support + files support.

Here my 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;
  } 
})

my console returns me :

UnhandledPromiseRejectionWarning: Error: Chunk.entrypoints: Use Chunks.addGroup instead

I can't figure out what fails.

If anybody have an hint, would be great,

Thanks

I'm working with NextJS and I'm trying to custom my configuration. So far, I have tried to add CSS support + files support.

Here my 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;
  } 
})

my console returns me :

UnhandledPromiseRejectionWarning: Error: Chunk.entrypoints: Use Chunks.addGroup instead

I can't figure out what fails.

If anybody have an hint, would be great,

Thanks

Share Improve this question edited Dec 16, 2018 at 19:26 Nikhil Kinkar 7819 silver badges31 bronze badges asked Aug 8, 2018 at 3:27 Diagathe JosuéDiagathe Josué 12.2k14 gold badges49 silver badges93 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Have you tried wrapping it in other ways? This might work (not 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);

} }

Also there is a withImages wrapper, https://github./twopluszero/next-images

const withImages = require('next-images') 
module.exports = withImages(withCss())
发布评论

评论列表(0)

  1. 暂无评论