Linaria + Next.js webpack configuration
See original GitHub issueUsing react and nextjs. The div element gets the className: ci74fup
but no styles are applied. What am I missing?
Am I limited to using only the react-helpers?
import React from 'react'
import Head from 'next/head'
import { css } from 'linaria';
const container = css`
background-color: red;
`;
export default () => {
return (
<>
<Head><title>CSS Playground</title></Head>
<div className={container}>
Hello World
</div>
</>
)
}
.babelrc
{ "presets": ["next/babel", "linaria/babel"] }
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (2 by maintainers)
Top Results From Across the Web
How can i use Linaria with NextJS? - Stack Overflow
There is a recent linaria issue on this topic. It seems people are finding success with the following next.config.js config:
Read more >Custom Webpack Config - Next.js
The webpack function is executed twice, once for the server and once for the client. This allows you to distinguish between client and...
Read more >Next.js, Preact, TS, twin.macro, Linaria - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >next-linaria - npm Package Health Analysis - Snyk
Adds Linaria to built-in CSS support in Next.js. The version 1.0.0 and above only works with linaria@3. If you need support for linaria@2,...
Read more >@biowaffeln/next-linaria NPM | npm.io
Check @biowaffeln/next-linaria 0.0.1 package - Last release 0.0.1 with MIT licence at our NPM ... module.exports = withLinaria(/* webpack config here */);.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank @LukasBombach. Your config is really nice and clean.
However, it doesn’t work with latest Next.js 9.4 for
next dev
mode. It is because during dev mode,config.module.rules[0].use
is an Array for the client side build. Something like this:So I have adjusted the config a little to cater for both dev and production build:
hey @orpheus thanks for your answer, I could simplify this even:
add linaria
.babelrc
next.config.js
I made a tutorial: https://gist.github.com/LukasBombach/dc46546919ecf71b2aa68688ee767e4e