Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能不能出一个详细的如何在create-react-app创建的框架中配置该插件的教程,或者阿里的umi如何使用该插件 #54

Open
YanLong9 opened this issue Nov 8, 2021 · 1 comment

Comments

@YanLong9
Copy link

YanLong9 commented Nov 8, 2021

No description provided.

@zkp442910864
Copy link

[email protected]

// chainWebpack 扩展配置
// 路径 config\plugin.config.js
config.module
    .rule('less')
    .use('scoped-css-loader')
    .loader('scoped-css-loader')
    .after('css-loader')
    .end();

config.module
    .rule('less-in-node_modules')
    .use('scoped-css-loader')
    .loader('scoped-css-loader')
    .after('css-loader')
    .end();
// 路径 config\config.js

// 增加属性
extraBabelPlugins: [
    [
        'babel-plugin-react-scoped-css',
        {
            // exclude: [path.resolve(__dirname, '.', '/src/assets/style/common.less')],
            // 包含 common.less 都会被过滤
            // include: '^((?!common.less).)*.(sa|sc|le|c)ss$',
            // 只对带有 scoped 名称的起作用
            include: '.scoped.(sa|sc|le|c)ss$',
        },
    ],
],

// 最重要一步
// cssLoaderOptions 这个s属性里面要把 .scoped.less 文件过滤掉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants