From 2df8db882d2e022e1c91cd17ee0dc0239b62641a Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Sat, 20 May 2017 22:26:57 +1200 Subject: [PATCH 1/2] Add css modules with [name].modules.css file convention --- README.md | 1 - .../config/webpack.config.dev.js | 53 +++++++++++----- .../config/webpack.config.prod.js | 63 ++++++++++++++----- .../features/webpack/CssModulesInclusion.js | 15 +++++ .../webpack/CssModulesInclusion.test.js | 19 ++++++ .../features/webpack/assets/style.modules.css | 4 ++ packages/react-scripts/template/README.md | 45 +++++++++++++ 7 files changed, 171 insertions(+), 29 deletions(-) create mode 100644 packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssModulesInclusion.js create mode 100644 packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssModulesInclusion.test.js create mode 100644 packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.modules.css diff --git a/README.md b/README.md index 8cd74f24f86..90c1c35b0fd 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,6 @@ Some features are currently **not supported**: * Server rendering. * Some experimental syntax extensions (e.g. decorators). -* CSS Modules. * Importing LESS or Sass directly ([but you still can use them](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)). * Hot reloading of components. diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index adf92f5b124..4a83fb04483 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -32,6 +32,24 @@ const publicUrl = ''; // Get environment variables to inject into our app. const env = getClientEnvironment(publicUrl); +// Options for PostCSS as we reference these options twice +// Adds vendor prefixing to support IE9 and above +const postCSSLoaderOptions = { + ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options + plugins: () => [ + require('postcss-flexbugs-fixes'), + autoprefixer({ + browsers: [ + '>1%', + 'last 4 versions', + 'Firefox ESR', + 'not ie < 9', // React doesn't support IE8 anyway + ], + flexbox: 'no-2009', + }), + ], +}; + // This is the development configuration. // It is focused on developer experience and fast rebuilds. // The production configuration is different and lives in a separate file. @@ -204,8 +222,9 @@ module.exports = { // "style" loader turns CSS into JS modules that inject