8000 How do I set in CRA with craco? · Issue #54 · yenshih/style-resources-loader · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How do I set in CRA with craco? #54

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

Open
CoderAWei opened this issue May 18, 2022 · 2 comments
Open

How do I set in CRA with craco? #54

CoderAWei opened this issue May 18, 2022 · 2 comments
8000

Comments

@CoderAWei
Copy link

I want to auto import less variables in all files, but fails. Here are my settings:

// craco.config.js
module.export = {
  plugins: [
    {
       plugin: styleResourcesLoader,
       options: {
         patterns: path.resolve(__dirname, './src/styles/variables.less')
       }
    }
  ]
}

It doesn't work! How can I fix it? Thanks!!!!

@candy4290
Copy link
candy4290 commented Oct 26, 2022

same question!!!help!!! @CoderAWei
I do like this:
configure: webpackConfig => { const loaders = webpackConfig.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf; loaders.push({ test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader', { loader: 'style-resources-loader', options: { patterns: [ path.resolve(__dirname, 'src/styles/_variable.less'), ], injector: 'append' } }] }) return webpackConfig }
It doesn't work too!

@candy4290
Copy link
candy4290 commented Oct 26, 2022

I want to auto import less variables in all files, but fails. Here are my settings:

// craco.config.js
module.export = {
  plugins: [
    {
       plugin: styleResourcesLoader,
       options: {
         patterns: path.resolve(__dirname, './src/styles/variables.less')
       }
    }
  ]
}

It doesn't work! How can I fix it? Thanks!!!!

module.exports = {
 plugins: [
   {
     plugin: CracoLessPlugin,
     options: {
       modifyLessRule: (lessRule) => {
         console.log(JSON.stringify(lessRule))
         lessRule.use.push({
           loader: 'style-resources-loader',
           options: {
               patterns: path.resolve(__dirname, 'src/styles/_variable.less'),
               injector: 'append'
           }
         })
         return lessRule
       },
       lessLoaderOptions: {
         lessOptions: {
           javascriptEnabled: true,
         },
       },
     },
   },
 ]
}

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
0