简体   繁体   English

Node-SASS 源映射不适用于 React-JS

[英]Node-SASS source maps not working with React-JS

I am trying to use SASS with REACT我正在尝试将 SASS 与 REACT 一起使用

Dummy GITHUB : https://github.com/bansalvks/react-poc-collection/tree/master/scss-with-react虚拟 GITHUB: https : //github.com/bansalvks/react-poc-collection/tree/master/scss-with-react

The problem I am facing is that the source maps are not working.我面临的问题是源映射不起作用。

I am using node-sass-chokidar and using the following script to run the utility node-sass-chokidar --include-path ./node_modules/ ./src -o ./src --output-style=expanded --source-map=true --source-map-root=true --watch我正在使用node-sass-chokidar并使用以下脚本运行实用程序node-sass-chokidar --include-path ./node_modules/ ./src -o ./src --output-style=expanded --source-map=true --source-map-root=true --watch

As you can see in the screen shot below the file is not appearing正如您在下面的屏幕截图中看到的,文件没有出现

在此处输入图片说明

This work with create-react-app but you can try in your react setup这与create-react-app 一起使用,但您可以尝试在您的反应设置中

Try this:尝试这个:

From "Dummy" Github webpage I found this:从“虚拟”Github 网页我发现了这个:

https://github.com/facebook/create-react-app/issues/5707 https://github.com/facebook/create-react-app/issues/5707

The following did work for me:以下对我有用:

 1.) open node_modules\\react-scripts\\config\\webpack.config.js 2.) replace "isEnvProduction" with "isEnvDevelopment" for the css-loader, css-module loader, sass loader and sass module loader (between lines 443 - 500) 3.) start development process with "npm start"

So simply, navigate to node_modules\\react-scripts\\config\\webpack.config.js很简单,导航到node_modules\\react-scripts\\config\\webpack.config.js

Between lines 443-500 search for:在第 443-500 行之间搜索:

  • css-loader css加载器
  • css-module css 模块
  • loader装载机
  • sass-loader sass-loader
  • sass-module-loader sass-module-loader

and replace isEnvProduction to isEnvDevelopment并将isEnvProduction替换为isEnvDevelopment

https://user-images.githubusercontent.com/11925409/50423483-4b986900-0856-11e9-80bb-7f7f331e17fd.png https://user-images.githubusercontent.com/11925409/50423483-4b986900-0856-11e9-80bb-7f7f331e17fd.png

I have tried that and source maps now are working in chrome developer tools我已经尝试过了,源地图现在可以在 Chrome 开发人员工具中使用

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

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