如何有效地将 node-sass 与 create-react-app 2 一起使用?
How exactly to use node-sass with create-react-app 2 efficiently?
所以,对于create-react-app
@v1,我曾经写gulp
任务来缩小和编译SASS,这不是实时的,但现在在create-react-app
@v2,Facebook 已经支持node-sass
实时编译反映变化。所以,我的问题是
With node-sass, where do I put my styles.scss
?
我试过把它放在 index.html
中,但它不起作用,所以也许 index.js 可以解决问题?
Will CRA2 minify my SASS in styles.min.css
once I npm run build
?
将您的样式放入 /src/App.scss
,并更新 src/App.js
(顶级 JS file/index)以包含 App.scss
而不是 .css
。这将导致 CRA 自动 compile/post-process SCSS。
另请参阅:https://facebook.github.io/create-react-app/docs/adding-a-sass-stylesheet
所以,对于create-react-app
@v1,我曾经写gulp
任务来缩小和编译SASS,这不是实时的,但现在在create-react-app
@v2,Facebook 已经支持node-sass
实时编译反映变化。所以,我的问题是
With node-sass, where do I put my
styles.scss
?
我试过把它放在 index.html
中,但它不起作用,所以也许 index.js 可以解决问题?
Will CRA2 minify my SASS in
styles.min.css
once Inpm run build
?
将您的样式放入 /src/App.scss
,并更新 src/App.js
(顶级 JS file/index)以包含 App.scss
而不是 .css
。这将导致 CRA 自动 compile/post-process SCSS。
另请参阅:https://facebook.github.io/create-react-app/docs/adding-a-sass-stylesheet