Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on require image #100

Open
donald-stolz opened this issue Aug 8, 2019 · 0 comments
Open

Error on require image #100

donald-stolz opened this issue Aug 8, 2019 · 0 comments

Comments

@donald-stolz
Copy link

donald-stolz commented Aug 8, 2019

Hi,
I'm trying to require a png:
src={require('../../static/images/landing/payment1.png')}

and am getting this error:

client dstolz$ yarn build
yarn run v1.17.3
warning ../package.json: No license field
$ next build
Creating an optimized production build ...

> Using external babel configuration
> Location: "/Users/dstolz/unstoppable-domains-website/client/.babelrc"
Failed to compile.

./static/images/landing/domain1.png
TypeError: Cannot read property 'context' of undefined

> Build error occurred
Error: > Build failed because of webpack errors
    at Object.build [as default] (/Users/dstolz/unstoppable-domains-website/client/node_modules/next/dist/build/index.js:192:15)
error Command failed with exit code 1.

I posted a comment in issue #36. In that issue, it was mentioned this could be related to my config so here's my current config

// next.config.js
require('dotenv').config();
const prod = process.env.NODE_ENV === 'production';
const path = require('path');
const Dotenv = require('dotenv-webpack');
const typeScript = require('@zeit/next-typescript');
const optimizedImages = require('next-optimized-images');
const withPlugins = require('next-compose-plugins');
const nextCSS = require('@zeit/next-css');

const nextConfig = {
  webpack: config => {
    config.plugins = config.plugins || [];

    config.plugins = [
      ...config.plugins,

      // Read the .env file
      new Dotenv({
        path: prod
          ? path.join(__dirname, '.env.production')
          : path.join(__dirname, '.env.dev'),
        systemvars: true,
      }),
    ];

    return config;
  },
  onDemandEntries: {
    // This governs the behavior of the development server ONLY
    // period (in ms) where the server will keep pages in the buffer
    maxInactiveAge: 5 * 60 * 1000,
    // number of pages that should be kept simultaneously without being disposed
    pagesBufferLength: 10,
  },
  distDir: 'build',
};

module.exports = withPlugins(
  [[optimizedImages], [typeScript], [nextCSS]],
  nextConfig,
);
@donald-stolz donald-stolz changed the title cl Error on require image Aug 8, 2019
@donald-stolz donald-stolz reopened this Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant