Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Enable hybrid css loader with both scoped and non scoped styles

At present every .less files expect to be loaded as modules and javascript enabled from webpack configuration.

Hence we need to load style sheets as

import style form './styles.less'

Usage: {style.container}

So with this, we are not able to apply global themes as it's scoped.

Can we have an option without a scope too along with scoping as an option provided?

Below is the Configuration:

   {
      loader: 'less-loader',
      options: {
        javascriptEnabled: true,
        modifyVars: themeVariables
      }
    }

And the css-loader configuration for the same is as below:

      {
          loader: 'css-loader',
          options: {
            importLoaders: 2,
            modules: true,
            camelCase: true,
            localIdentName: '[name]__[local]',
            getLocalIdent: (
              loaderContext,
              localIdentName,
              localName,
              options
            ) => {
              if (!options.context) {
                options.context = loaderContext.rootContext;
              }

              const request = path
                .relative(options.context, loaderContext.resourcePath)
                .replace(/\\/g, '/');
              const segs = request.split('/');
              let name = segs[segs.length - 2];
              if (name === 'style') {
                name = segs[segs.length - 3];
              }

              return name + '_' + localName;
            }
          }
        },

The expectation is to load .less files without using variables

import './styles.less'

Usage: '.container'

Tried to add exportGlobals: true, for css-loader options but it throws an error as options should NOT have additional properties

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!