解决不支持引用css文件

  1. yarn add @zeit/next-css
  2. // next.config.js
  3. const withCss = require('@zeit/next-css')
  4. if (typeof require !== 'undefined') {
  5. require.extensions['.css'] = file => []
  6. }
  7. module.exports = withCss({})

antd 按需加载

  1. yarn add antd
  2. yarn add babel-plugin-import
  1. // .babelrc
  2. {
  3. "presets": ["next/babel"],
  4. "plugins": [
  5. [
  6. "import",
  7. {
  8. "libraryName": "antd"
  9. }
  10. ]
  11. ]
  12. }
  13. // page / _app.js
  14. import App from 'next/app'
  15. import 'antd/dist/antd.css'
  16. export default App