zoukankan      html  css  js  c++  java
  • create-react-app脚手架中配置sass

    本文介绍如何在react中配置sass

    首先将你的文件名称改成scss结尾的文件
    然后安装依赖 cnpm install sass-loader node-sass --save-dev
    找到node_modules/react-scripts/config/webpack.config.dev.js文件和webpack.config.prod.js文件
    将module配置项的最后一项配置改成如下
    {
        loader: require.resolve('file-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$/],
        options: {
             name: 'static/media/[name].[hash:8].[ext]',
        },
    },
    {
        test: /.scss$/,
        loaders: ['style-loader', 'css-loader', 'sass-loader'],
    }
    到此,配置完毕,记得两个文件都要改
    
  • 相关阅读:
    关于LockSupport
    Sqrtx
    Text Justification
    Unique Paths II
    N-Queens
    Anagrams
    CSipSimple通话记录分组
    CSipSimple配置系统
    Permutations II 再分析
    CSipSimple的插件结构
  • 原文地址:https://www.cnblogs.com/ye-hcj/p/7753085.html
Copyright © 2011-2022 走看看