Hashnode / mern-starter

⛔️ DEPRECATED - Boilerplate for getting started with MERN stack
MIT License
5.15k stars 1.18k forks source link

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

Open sdimmick opened 7 years ago

sdimmick commented 7 years ago

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'),
},
mannyhenri commented 6 years ago

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