Skip to content

Commit

Permalink
postcss-extend integration (#42)
Browse files Browse the repository at this point in the history
* first pass at postcss-extend support

* resolve build warning
  • Loading branch information
Brian Staruk authored May 12, 2018
1 parent 2610126 commit d470355
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"extends": "stylelint-config-standard",
"rules": {
"at-rule-no-unknown": [
true,
{
"ignoreAtRules": [
"extend"
]
}
],
"property-no-unknown": [
true,
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ starbase is a webpack 4, ES6 & PostCSS boilerplate that utilizes some of the jui
* [cssnext](https://github.com/MoOx/postcss-cssnext)
* [PostCSS Nested](https://github.com/postcss/postcss-nested)
* [PostCSS Responsive Type](https://github.com/seaneking/postcss-responsive-type)
* [postcss-extend](https://github.com/travco/postcss-extend)
* [stylelint](https://github.com/stylelint/stylelint)
* [MQPacker](https://github.com/hail2u/node-css-mqpacker)
* ...and more!
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"offline-plugin": "^5.0.3",
"postcss": "^6.0.22",
"postcss-cssnext": "^3.1.0",
"postcss-extend": "^1.0.5",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.5",
"postcss-nested": "^3.0.0",
Expand Down
7 changes: 7 additions & 0 deletions src/app/utilities.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.clearfix {
&::after {
content: "";
display: table;
clear: both;
}
}
10 changes: 4 additions & 6 deletions src/components/tabs/tabs.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "../../app/utilities.css";

:root {
--tabs-list-height-small: 2rem;
--tabs-list-height-full: 2.5rem;
Expand All @@ -15,6 +17,8 @@

/* tabs list */
&__list {
@extend .clearfix;

list-style-type: none;
margin: 0;
padding: 0;
Expand All @@ -28,12 +32,6 @@
border-bottom: 2px solid var(--tabs-border-color);
}

&::after {
content: "";
display: table;
clear: both;
}

& > li {
float: left;
margin: 0.5rem 0.5rem 0 0;
Expand Down
10 changes: 7 additions & 3 deletions webpack/lib/css-prefix-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ const loaderUtils = require('loader-utils');

module.exports = function cssPrefixVariables(content) {
const options = loaderUtils.getOptions(this);

if (options.path) {
this.cacheable();
return `@import url("${options.path}");\n\n${content}`;
} else {
return content;

// check if first line of content is another import
const lineBreak = content.substr(0, 7) === '@import' ? '\n' : '\n\n';
return `@import url("${options.path}");${lineBreak}${content}`;
}

return content;
};
10 changes: 6 additions & 4 deletions webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const postcssCssnext = require('postcss-cssnext');
const postcssNested = require('postcss-nested');
const postcssRemoveRoot = require('postcss-remove-root');
const postcssResponsiveType = require('postcss-responsive-type');
const postcssExtend = require('postcss-extend');
const cssMqpacker = require('css-mqpacker');

module.exports = webpackMerge(webpackConfigBase, {
Expand All @@ -29,19 +30,20 @@ module.exports = webpackMerge(webpackConfigBase, {
options: {
sourceMap: 'inline',
plugins: () => [
postcssImport,
stylelint(),
postcssReporter(),
postcssImport(),
postcssNested(),
postcssCssnext({
features: {
autoprefixer: {
grid: false
}
}
}),
postcssResponsiveType,
postcssNested,
postcssRemoveRoot,
postcssResponsiveType(),
postcssExtend(),
postcssRemoveRoot(),
cssMqpacker({
sort: true
})
Expand Down
10 changes: 6 additions & 4 deletions webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const postcssCssnext = require('postcss-cssnext');
const postcssNested = require('postcss-nested');
const postcssRemoveRoot = require('postcss-remove-root');
const postcssResponsiveType = require('postcss-responsive-type');
const postcssExtend = require('postcss-extend');
const cssMqpacker = require('css-mqpacker');
const cssnano = require('cssnano');

Expand All @@ -30,19 +31,20 @@ module.exports = webpackMerge(webpackConfigBase, {
loader: 'postcss-loader',
options: {
plugins: () => [
postcssImport,
stylelint(),
postcssReporter(),
postcssImport(),
postcssNested(),
postcssCssnext({
features: {
autoprefixer: {
grid: false
}
}
}),
postcssResponsiveType,
postcssNested,
postcssRemoveRoot,
postcssResponsiveType(),
postcssExtend(),
postcssRemoveRoot(),
cssMqpacker({
sort: true
}),
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6435,6 +6435,12 @@ postcss-discard-unused@^2.2.1:
postcss "^5.0.14"
uniqs "^2.0.0"

postcss-extend@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/postcss-extend/-/postcss-extend-1.0.5.tgz#5ea98bf787ba3cacf4df4609743f80a833b1d0e7"
dependencies:
postcss "^5.0.4"

postcss-filter-plugins@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/postcss-filter-plugins/-/postcss-filter-plugins-2.0.2.tgz#6d85862534d735ac420e4a85806e1f5d4286d84c"
Expand Down

0 comments on commit d470355

Please sign in to comment.