I ended up resolving this by going a different route; probably the best-practice in this situation. I'll post my solution in case it's helpful.
I just used next-css (see update at the bottom of the post), and a javscript import to include the files. I'll post code below. I found a couple benefits to this way of doing it:
- Next.js automatically catches changes and rebuilds.
- Sourcemaps work better. Before, when I clicked on the source of a style in dev tools, it would just point me to my
<style>@import...
statement. Not helpful. EDIT: Actually, sourcemap seems to be broken for me. Something to do with postcss and next-css not playing well together, I think.
In the end, this is probably a better way to do it. Though, I'd still like to know if there's a resolution that works with what I posted originally.
_app.js
@import 'path/to/global.css'
export default const App = ({Component, pageProps}) => {
return (
<Component {...pageProps} />
)
};
To forestall questions, there is more to this file than I'm showing. Really just including it to show the difference between my original post and the solution.
global.css
@import '@css/variables.css';
@import '@css/mixins.css';
@import '@css/reset.css';
@import '@css/body.css';
@import '@css/grid.css';
@import '@css/form.css';
next.config.js
const withCSS = require('@zeit/next-css')
module.exports = withCSS({})
UPDATE (01/26/20): Next.js 9.2 now has built-in support for importing CSS files. So you can get rid of the next-css
stuff. Plus it fixes sourcemaps; so that works great.