scss样式预编译的工具就不多解释,网上的介绍非常多。
只说在react项目中的配置。
创建完项目后,要执行npm eject 也就是打开全部配置项。
安装依赖:yarn add sass-loader node-sass
找到config里面的两个配置文档。
配置的内容都是一样的。
代码是:{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader'],
},
{
// Exclude `js` files to keep "css" loader working as it injects
// it's runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.js$/, /\.html$/, /\.json$/,/\.scss$/],
loader: require.resolve('file-loader'),
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
本文详细介绍如何在React项目中配置SCSS样式预编译工具。包括如何启用完整配置选项、安装必要依赖以及具体配置步骤。
1102

被折叠的 条评论
为什么被折叠?



