Skip to content

main.css should not be loaded as CSS module via webpack #300

Open

Description

@sdimmick

client/main.css is a standard, non-module stylesheet, but according to the CSS loaders defined in webpack.config.prod.js, it appears to be treated as a CSS module:

{
  test: /\.css$/,
  exclude: /node_modules/,
  loader: ExtractTextPlugin.extract('style-loader', 'css-loader?localIdentName=[hash:base64]&modules&importLoaders=1!postcss-loader'),
}, {
  test: /\.css$/,
  include: /node_modules/,
  loaders: ['style-loader', 'css-loader'],
}

This results in the stylesheet being loaded separately after the main HTML content of the page instead of with the main CSS manifest at the top of the page, as it should.

One potential solution would be to move non-module stylesheets into a separate directory, and define separate webpack loaders: one for CSS modules, and one for standard CSS files.

Something like:

var rawCSSDir = path.join(__dirname, 'client/style');

{
  test: /\.css$/,
  exclude: [/node_modules/, rawCSSDir],
  loader: ExtractTextPlugin.extract('style-loader', 'css-loader?localIdentName=[hash:base64]&modules&importLoaders=1!postcss-loader'),
}, {
  test: /\.css$/,
  include: rawCSSDir,
  loader: ExtractTextPlugin.extract('style-loader', 'css-loader?localIdentName=[hash:base64]&importLoaders=1!postcss-loader'),
},

Activity

  1. added this to the 2.5.0 milestone on Jun 2, 2018
  2. mannyhenri commented on Jun 2, 2018

    @mannyhenri
    Contributor

    @rosariorussell you wan to take a look at this one?

  3. added
    V2.6.0Webpack update V4
    and removed on Jul 12, 2018
  4. modified the milestones: 2.5.0, 2.6.0 on Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    V2.6.0Webpack update V4

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions