我正在尝试创建React Web App,并决定使用Suitcss组件。我已经使用npm成功安装了组件,但是编译存在问题。
当我在我的src / index.scss文件中添加 @import'suitcss'; 并在终端中运行 npm run build 命令时,我得到归档进行编译屏幕错误,控制台向我显示:
./src/index.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-3!./src/index.scss)
@import "suitcss";
^
File to import not found or unreadable: suitcss.
in /Users/macmini1/Desktop/react-calculator/src/index.scss (line 1, column 1)
看起来好像在node_modules文件夹中找不到合适的文件,但是我检查了文件是否在其中。
我的package.json文件还显示已安装组件
"name": "react-calculator",
"version": "0.1.0",
"private": true,
"dependencies": {
"cssnano": "^4.1.10",
"js-yaml": "^3.13.1",
"node-sass": "^4.12.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "^3.0.1",
"rework-npm": "^1.0.0",
"suitcss": "^3.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build suitcss index.scss build/build.css",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
最后,必须将结果编译到 build 文件夹中的文件(build.css)。