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

Issue with css-loader when passing options with function prop #58

Closed
ShinyChang opened this issue Jan 31, 2019 · 4 comments
Closed

Issue with css-loader when passing options with function prop #58

ShinyChang opened this issue Jan 31, 2019 · 4 comments

Comments

@ShinyChang
Copy link

ShinyChang commented Jan 31, 2019

Environment

OS: Mac OS 10.14
css-loader: 2.1.0
thread-loader: 2.1.2
webpack: 4.28.4

Description
The getLocalIdent which is a custom function in the option of css-loader. It appear in the thread-loader option but not in the css-loader option. As below image shows:
image

loader configuration:

    'cache-loader',
    {
      loader: 'thread-loader',
      options: workerPool
    },
    {
      loader: 'css-loader',
      options: {
        context: path.resolve(__dirname, '..', '..', 'src'),
        modules: true,
        exportOnlyLocals,
        localIdentName: '[path]__[name]__[local]',
        getLocalIdent: (context, localIdentName, localName) => genLocalIdent(localName, context.resourcePath),
        importLoaders: 2
      }
    },
    'postcss-loader',
    {
      loader: 'sass-loader',
      options: {
        outputStyle: 'expanded',
        includePaths: [
          path.resolve(__dirname, '..', '..', 'src/component-library/_styles'),
          path.resolve(__dirname, '..', '..', 'src/css')
        ]
      }
    }

It works fine without thread-loader, so I think this should be thread-loader issue.

Please checkout sample repo and test it

@ShinyChang
Copy link
Author

@sokra @ericclemmons , I know you are super busy. But please take a look of this issue. I already created minimum reproduce configuration for you. Please give me some ideas how to resolve it, or what's the root cause.

@sokra
Copy link
Member

sokra commented Feb 3, 2019

This can't be fixed by design. Closures are not transferrable cross thread/process.

But you can move the thread-loader after the css-loader to run sass and postcss in parallel.

@ShinyChang
Copy link
Author

Thanks for your reply. I will adjust the order of loaders.

@DemonCloud
Copy link

@sokra Thanks very much , the bug when use (thread-loader|cache-loader) with css-loader togather, It will ignore css-loader options as getLocalIdent

BUPTlhuanyu added a commit to BUPTlhuanyu/thread-loader that referenced this issue Dec 19, 2021
BUPTlhuanyu added a commit to BUPTlhuanyu/thread-loader that referenced this issue Dec 19, 2021
BUPTlhuanyu added a commit to BUPTlhuanyu/thread-loader that referenced this issue Dec 19, 2021
BUPTlhuanyu added a commit to BUPTlhuanyu/thread-loader that referenced this issue Dec 30, 2021
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

3 participants