adding cleanslate support for style scoping

This commit is contained in:
Benjamin Boudreau
2018-06-09 08:43:18 -04:00
parent 4e01bb3fd6
commit 81517491d5
9 changed files with 1045 additions and 384 deletions

View File

@@ -1,10 +1,13 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const increaseSpecificity = require('postcss-increase-specificity');
const devMode = process.env.NODE_ENV !== 'production';
const defaultConfig = {
mode: 'production',
plugins: [
new CleanWebpackPlugin(['dist/']),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
@@ -20,11 +23,25 @@ const defaultConfig = {
use: ['babel-loader'],
},
{
test: /\.scss$/,
test: /\.(scss|css)$/,
use: [
// fallback to style-loader in development
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'cssimportant-loader',
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [
increaseSpecificity({
stackableRoot: '.cleanslate',
repeat: 1,
}),
],
sourceMap: devMode,
},
},
'sass-loader',
],
},