Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Doesn't work with mini-css-extract #40

Closed
guylando opened this issue Aug 4, 2018 · 12 comments
Closed

Doesn't work with mini-css-extract #40

guylando opened this issue Aug 4, 2018 · 12 comments

Comments

@guylando
Copy link

guylando commented Aug 4, 2018

If cache-loader cached files in the .cache-loader folder then on following builds mini-css-extract does not extract css files.

@alexander-akait
Copy link
Member

@guylando What? How it is related to extract? Please provide reproducible test repo

@guylando
Copy link
Author

guylando commented Aug 4, 2018

@evilebottnawi Here is the code to reproduce with steps to reproduce in the readme
https://github.com/guylando/WebpackCacheExtractCssBug

@alexander-akait
Copy link
Member

alexander-akait commented Aug 4, 2018

@guylando you use invalid configuration, cache-loader should be before fast-css-loader

@guylando
Copy link
Author

guylando commented Aug 4, 2018

@evilebottnawi I dont understand. The cache-loader appears before fast-css-loader in the array.
Can you please give example of the required fix?

@guylando
Copy link
Author

guylando commented Aug 4, 2018

@evilebottnawi Also would be helpful if you know where can I read the documentation about this (couldn't find information about this in google..)

@guylando
Copy link
Author

guylando commented Aug 4, 2018

Fixed by changing order between cache-loader and mini-css-extract loader but it kind of ruins the point of caching because mini-css-extract will exctract css each time even if cache is used.

@guylando
Copy link
Author

guylando commented Aug 4, 2018

So I still believe cache-loader and mini-css-extract dont work as desired when together.

@alexander-akait
Copy link
Member

@guylando cache-loader caching modules, extract css is not create modules and can't works by design

@guylando
Copy link
Author

guylando commented Aug 4, 2018

@evilebottnawi mini-css-extract could add caching ability as following: when receiving a module from previous loader, either cache-loader or css loader, then to hash the result in a way that can be compared for future builds. Similar to how other plugins implemented caching. Unless mini-css-extract actions are neglible time-wise, this will create a major performance improvement for mini-css-extract usage.

@alexander-akait
Copy link
Member

@guylando PR welcome

@jerryOnlyZRJ
Copy link

There is a hack for this issue:

You can put your cache-loader behind your mini-css-extract-plugin, like this:

{
    ...,
    {
        test: /\.(less|css)$/,
        use: [
          _mode === 'development' ? 'style-loader' : MiniCssExtractPlugin.loader,
          'cache-loader',
          {
            loader: 'css-loader',
            options: {
               importLoaders: 1,
               import: true,
             },
          },
          'postcss-loader',
        ],
      },
}

It seems to work well.

@guylando
Copy link
Author

@jerryOnlyZRJ Read this: #40 (comment)

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

No branches or pull requests

3 participants