likes
comments
collection
share

styled-jsx: plugins is not a function

作者站长头像
站长
· 阅读数 554

在使用使用Next.js做开发时很多开发者会选择styled-jsx作为CSS方案,同时会使用styled-jsx-plugin-sass插件使styled-jsx支持Sass预处理,但是某一次使用时发现出现了如下错误:

event - build page: /
wait  - compiling...
info  - Using external babel configuration from /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/.babelrc
error - ./pages/index.js
TypeError: /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/pages/index.js: plugins is not a function
event - build page: /next/dist/pages/_error
wait  - compiling...
error - ./pages/index.js 
TypeError: /home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/pages/index.js: plugins is not a function 
Error: Cannot find module '/home/m1ck0/Desktop/projects/test-next-style/with-styled-jsx-scss-app/.next/server/pages-manifest.json'

主要报错内容:plugins is not a function,在查阅相关的issues后找到解决方案,我发布了一篇styled-jsx中使用Sass的文章(这个GitHub issues中也有写到),文章地址,主要内容就是旧的插件不在维护现在使用@styled-jsx/plugin-sass作为styled-jsx中的预处理插件。正向插件中所说的,该插件是对旧插件的优化,开发者直接安装无缝替换就可以。

styled-jsx: plugins is not a function