简体   繁体   English

在CSS文件中进行更改后,CSS文件未显示更改

[英]css file not showing changes after making changes in scss file

I just converted scss file into css file using npm as per the instructions on this link to instructions and it worked fine for the first time and scss file compiled with a css file autogenerated but now when I make changes to scss file , I don't see css file to change on its own and I have to use npm run watch-css every time and then run the server .Is there any way to do this such that I don't have to run server again and again? 我只是按照说明链接上的说明使用npm将scss文件转换为css文件并且它第一次可以正常工作,并且自动生成了具有css文件编译的scss文件,但是现在当我对scss文件进行更改时,我没有看到css文件自行更改,我必须每次使用npm run watch-css然后运行服务器。是否有任何方法可以执行此操作,而不必一次又一次运行服务器?

I am adding the package.json file . 我正在添加package.json文件。

{
  "name": "mydecisionapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "css": "^2.2.1",
    "loader": "^2.1.1",
    "node-sass-chokidar": "0.0.3",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-modal": "^3.1.11",
    "react-scripts": "1.1.0",
    "style": "^0.0.3",
    "validator": "8.0.0"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "css-loader": "^0.28.9",
    "node-sass": "^4.7.2",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.20.1",
    "webpack": "^3.10.0"
  }
}

In the instructions you have posted you will find the answer if you keep following the "Adding a CSS Preprocessor" section. 如果您始终遵循“添加CSS预处理程序”部分,则可以在已发布的说明中找到答案。

Install npm-run-all and modify your scripts section as follows 安装npm-run-all并按如下所示修改脚本部分

"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build-js": "react-scripts build",
"build": "npm-run-all build-css build-js",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"

This simply runs the two scripts in parallel, meaning that npm start will now both handle the watching of your scss files, and run the server 这只是并行运行两个脚本,这意味着npm start现在将同时处理监视您的scss文件并运行服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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