From 6b55f1ec721ae46cb01fe350cf477bbf03eabf69 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 13 Feb 2018 18:15:18 -0500 Subject: [PATCH] CSS modules EVERYWHERE! --- src/style.css | 4 +-- webpack.common.js | 69 +++++++++++++++-------------------------------- webpack.prod.js | 7 +++-- 3 files changed, 28 insertions(+), 52 deletions(-) diff --git a/src/style.css b/src/style.css index 9ce8c2a..82a4c1d 100644 --- a/src/style.css +++ b/src/style.css @@ -17,7 +17,7 @@ a { color: inherit; } -ul.inline { +ul:global(.inline) { list-style: none; margin: 0; padding: 0; @@ -28,7 +28,7 @@ ul.inline { white-space: nowrap; } - &.with-separator { + &:global(.with-separator) { & li:after { content: '//'; padding: 0 0.5rem; diff --git a/webpack.common.js b/webpack.common.js index 2250f22..66b5611 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -98,54 +98,27 @@ module.exports = { loader: 'babel-loader' }, { - oneOf: [ - { - test: /\.css$/, - exclude: /components/, - use: ExtractTextPlugin.extract({ - fallback: 'style-loader', - use: [ - { - loader: 'css-loader', - options: { - importLoaders: 1, - minimize: true, - sourceMap: true, - } - }, - { - loader: 'postcss-loader', - options: { - ident: 'postcss' - } - } - ] - }) - }, - { - test: /\.css$/, - use: ExtractTextPlugin.extract({ - fallback: 'style-loader', - use: [ - { - loader: 'css-loader', - options: { - importLoaders: 1, - minimize: true, - sourceMap: true, - modules: true - } - }, - { - loader: 'postcss-loader', - options: { - ident: 'postcss' - } - } - ] - }) - }, - ] + test: /\.css$/, + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: [ + { + loader: 'css-loader', + options: { + importLoaders: 1, + minimize: true, + sourceMap: true, + modules: true + } + }, + { + loader: 'postcss-loader', + options: { + ident: 'postcss' + } + } + ] + }) }, { test: /\.svg$/, diff --git a/webpack.prod.js b/webpack.prod.js index 9942ffb..1e550ec 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -43,9 +43,12 @@ module.exports = [ // Replace the rule for CSS files { test: /\.css$/, - loader: 'css-loader/locals' + loader: 'css-loader/locals', + options: { + modules: true + } }, - ...common.module.rules.filter(rule => !rule.oneOf) + ...common.module.rules.filter(rule => !rule.test.test('file.css')) ] } }