Skip to content

Instantly share code, notes, and snippets.

@Katerina198b
Last active March 4, 2021 08:04
Show Gist options
  • Save Katerina198b/55ebc35d6e41396ff63c482fb5dc5b4b to your computer and use it in GitHub Desktop.
Save Katerina198b/55ebc35d6e41396ff63c482fb5dc5b4b to your computer and use it in GitHub Desktop.
webpack.js
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: false,
plugins: () => [autoprefixer()],
},
};
const cssRules = [
{
// for css files that are imported WITHOUT modules
test: /\.(s?css)$/,
use: [
//extracts CSS into separate files
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false,
}
},
//autoprefixer
postcssLoader,
'sass-loader'
],
sideEffects: true,
//file listing
include: /(bootstrap|date)\.scss$/,
},
{
test: /\.(s?css)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
exportOnlyLocals: false,
getLocalIdent: (context, localIdentName, localName) => {
return generateScopedName(localName, context.resourcePath);
},
}
},
postcssLoader,
'sass-loader'
],
sideEffects: true,
exclude: /(bootstrap|date)\.scss$/,
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment