twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
949 stars 67 forks source link

Can't setup package. I get Error - Failed to Compile #22

Closed EladKarni closed 5 years ago

EladKarni commented 5 years ago

https://i.imgur.com/Z1Ga74q.png

Here is the error I'm getting

arefaslani commented 5 years ago

@EladKarni Could you share you NextJS configuration?

hutber commented 5 years ago

Have to say, coming new to jextjs I also had the same error. But I know fullwell i have not setup nextjs correctly.


import WebpackBar from 'webpackbar'
import withImages from 'next-images'

module.exports = {
  webpack: (config, { dev }) => {
    if (dev) {
      config.devtool = 'cheap-module-source-map'
    }
    config.mode = 'development'
    config.plugins.push(
      new WebpackBar({
        fancy: true,
        profile: true,
        basic: false,
      })
    )
    return config
  },
}

module.exports = withImages({
  webpack(config) {
    return config
  },
})
hutber commented 5 years ago

Updating to this:



import WebpackBar from 'webpackbar'
import withImages from 'next-images'

module.exports = withImages({
  webpack: (config, { dev }) => {
    if (dev) {
      config.devtool = 'cheap-module-source-map'
    }
    config.mode = 'development'
    config.plugins.push(
      new WebpackBar({
        fancy: true,
        profile: true,
        basic: false,
      })
    )
    return config
  },
})

I think this will fix it