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

Nextjs: Styled-components-breakpoint throws webpack error #25

Open
arthurpeck opened this issue Apr 27, 2020 · 4 comments
Open

Nextjs: Styled-components-breakpoint throws webpack error #25

arthurpeck opened this issue Apr 27, 2020 · 4 comments

Comments

@arthurpeck
Copy link

arthurpeck commented Apr 27, 2020

Hi,
After sucessfully used the styled-components-breakpoint in React in the past, I wanted to add styled-components-breakpoint to my components in NextJS.
When I use it, it throws an webpack error:

TypeError: styled_components_breakpoint__WEBPACK_IMPORTED_MODULE_4___default(...) is not a function

Component:

import breakpoint from 'styled-components-breakpoint';

const Logo = styled.img`
display: block;

${breakpoint('mobile')`
    width: 100%;
`}

${breakpoint('tablet')`
    width: 60%;
`}

${breakpoint('desktop')`
    width: 30%;
`}
;

next.config.js:

// next.config.js const withOptimizedImages = require('next-optimized-images'); const path = require('path'); module.exports = withOptimizedImages({ webpack(config) { config.resolve.alias.images = path.join(__dirname, 'public/images'); return config; }, });

Why is it throwing an error? I can use styled-components perfectly without breakpoints and webpack compiles...

@karlas
Copy link

karlas commented May 9, 2020

Same here with v3. Downgrading to version 2.1.1 works ok

@chargome
Copy link

Fixed the problem for me:

import { breakpoint } from 'styled-components-breakpoint';

@ernestrudziec
Copy link

import { breakpoint } from 'styled-components-breakpoint';

helped me also ;)

@eeshankeni
Copy link

it legit blows my mind we had the same silly issue, i need to code high less often

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

5 participants