Last active
March 23, 2019 17:13
-
-
Save kricore/505c14fb9c69d77184458499707c2d98 to your computer and use it in GitHub Desktop.
Kinda defeats the purpose of CSS modules but if you want to use (raw) Bootstrap alongside with CSS modules here you go:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "postcss" loader applies autoprefixer to our CSS. | |
// "css" loader resolves paths in CSS and adds assets as dependencies. | |
// "style" loader turns CSS into JS modules that inject <style> tags. | |
// In production, we use a plugin to extract that CSS to a file, but | |
// in development "style" loader enables hot editing of CSS. | |
// SASS loader | |
// https://medium.com/@Connorelsea/using-sass-with-create-react-app-7125d6913760 | |
{ | |
test: /\.scss$/, | |
include: paths.appSrc, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', | |
}, | |
{ | |
loader: 'sass-loader', | |
}, | |
{ | |
loader: require.resolve('postcss-loader'), | |
options: { | |
// Necessary for external CSS imports to work | |
// https://github.com/facebookincubator/create-react-app/issues/2677 | |
ident: 'postcss', | |
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', | |
}), | |
], | |
}, | |
} | |
] | |
}, | |
{ | |
test: /(\.bootstrap\.css$|bootstrap-theme.css|bootstrap.css)/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
minimize: true || {/* CSSNano Options */} | |
} | |
}, | |
], | |
}, | |
{ | |
test: /^((?!\.bootstrap|bootstrap-theme).)*\.css$/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', | |
}, | |
{ | |
loader: require.resolve('postcss-loader'), | |
options: { | |
// Necessary for external CSS imports to work | |
// https://github.com/facebookincubator/create-react-app/issues/2677 | |
ident: 'postcss', | |
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', | |
}), | |
], | |
}, | |
} | |
] | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment