Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

Not all styles included in extracted css #294

Closed
@KELiON

Description

@KELiON

How can I debug why not all css modules are included in final css bundle?

I've migrated to webpack 2 and rewrote my production config:

module: {
  loaders: [
    ...baseConfig.module.loaders,

    {
      test: /global\.css$/,
      loader: ExtractTextPlugin.extract(
        'style-loader',
        'css-loader'
      )
    },

    {
      test: /^((?!global).)*\.css$/,
      loader: ExtractTextPlugin.extract(
        'style-loader',
        'css-loader?modules&importLoaders=1&!postcss-loader'
      )
    }
  ]
}
...
plugins: [
  ...
  new ExtractTextPlugin('style.css', { allChunks: true }),
  ...
]

And now:

module: {
  rules: [
    ...baseConfig.module.rules,

    {
      test: /global\.css$/,
      loader: ExtractTextPlugin.extract({
        fallbackLoader: 'style-loader',
        loader: 'css-loader'
      })
    },
    {
      test: /^((?!global).)*\.css$/,
      loader: ExtractTextPlugin.extract({
        fallbackLoader: 'style-loader',
        loader: 'css-loader?modules&importLoaders=1!postcss-loader'
      })
    }
  ]
}
...
plugins: [
  ...
  new ExtractTextPlugin({
    filename: 'style.css',
    allChunks: true
  }),
  ...
]

First config works in webpack 1, but with new config and webpack 2 I see that a lot of styles are not in styles.css. How can I debug why it happens?

Also, if I use rules from development (without ExtractCss) it works:

{
  test: /global\.css$/,
  use: [
    'style-loader',
    {
      loader: 'css-loader',
      options: {
        sourceMap: true
      }
    }
  ]
},

{
  test: /^((?!global).)*\.css$/,
  use: [
    {
      loader: 'style-loader',
      options: {
        sourceMap: true
      }
    },
    {
      loader: 'css-loader',
      options: {
        modules: true,
        sourceMap: true,
        importLoaders: 1
      }
    },
    'postcss-loader'
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions