如何在nextjs中添加自定义CSS

时间:2020-05-30 04:32:37

标签: html css reactjs webpack next.js

我试图将这些Template添加到我的一个组件中,该组件还动态获取其他值。 但我却收到此错误

if (j == i) break;

我还在You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders中尝试过next-images,但仍然给我同样的错误。

这是我的package.json

next.config.js

更新:

我的next.config.js

{
  "name": "frontend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "build": "next",
    "start": "next start"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@zeit/next-css": "^1.0.1",
    "isomorphic-fetch": "^2.2.1",
    "js-cookie": "^2.2.1",
    "moment": "^2.25.3",
    "next": "^9.3.6",
    "nprogress": "^0.2.0",
    "prop-types": "^15.7.2",
    "query-string": "^6.12.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-modal": "^3.11.2",
    "react-quill": "^1.3.5",
    "react-render-html": "^0.6.0",
    "reactstrap": "^8.4.1"
  }
}

1 个答案:

答案 0 :(得分:1)

在您的next.config.js中尝试:

// next.config.js

const withCSS = require('@zeit/next-css')

module.exports = withCSS({

  cssLoaderOptions: {
    url: false

  }
})