Next.js: Config option to Allow importing CSS from any file

Created on 24 Feb 2020  路  5Comments  路  Source: vercel/next.js

Feature request

Is your feature request related to a problem? Please describe.

I'm using Linaria with Next.js which generates unique hashes for each className so it is safe to import the generated CSS globally.

Currently importing global CSS is only allowed in _app.js.

Describe the solution you'd like

It would be great if we had the option to allow css files to be imported from any file with a configuration option in next.config.js:
``` js
module.exports = {
css: {
importAsGlobal: true
}
}
````

Most helpful comment

If you use the next-css or next-sass plugins then it will automatically disable the new CSS handling and allow global imports.

All 5 comments

The built-in CSS feature was added in next.js version 9.2. This feature allows you to handle files using file naming conventions.

Yeah it's pretty great when writing css modules or global stylesheets, although as linaria inserts css import statements into each file that imports linaria, and the built-in css support does not allow importing global css files into any file (only _app.js), linaria currently does not work with built-in css support.

I found this thread trying to make Linaria work again as well.

If you use the next-css or next-sass plugins then it will automatically disable the new CSS handling and allow global imports.

Closing as duplicate of #12079

Was this page helpful?
0 / 5 - 0 ratings