简体   繁体   中英

Similar CSS chunks in Next.js

I'm trying to figure out why Next.js inserts two similar chunk of CSS, like so

<link rel="preload" href="/_next/static/css/styles.chunk.css" as="style"/>
<link rel="stylesheet" href="/_next/static/css/styles.chunk.css"/>

I want only one with rel equals "preload". What can I do for this? In my next.config.js is nothing criminal:

const withImages = require('next-images')
const withSass = require('@zeit/next-sass')
const TerserPlugin = require('terser-webpack-plugin')

const env = process.env.NODE_ENV || 'development'

const configs = {
  development: {
    BASE_URL: 'http://localhost:8110'
  },
  production: {
    BASE_URL: 'https://some-url'
  }
}[env]

module.exports = withSass(
  withImages({
    minified: true,
    optimization: {
      minimizer: [new TerserPlugin()]
    },
    env: {
      ...configs,
      ...other options
    }
  })
)

Thanks.

This is how preloading with link tags works.

If you check out the example on the MDN you will see a very similar layout as yours with a preload link, and then the stylesheet link.

Preloading Content With rel=preload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM