From e5a9c8926fc2ef978118305653d406776c15ccba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Heller=20=F0=9F=92=A9?= Date: Fri, 3 Nov 2017 20:52:16 +0100 Subject: [PATCH 1/5] remove empty media queries --- __tests__/sanity.test.js | 8 ++++++++ src/lib/substituteResponsiveAtRules.js | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/__tests__/sanity.test.js b/__tests__/sanity.test.js index 516d425f6..d79bcee57 100644 --- a/__tests__/sanity.test.js +++ b/__tests__/sanity.test.js @@ -17,3 +17,11 @@ it('generates the right CSS', () => { expect(result.css).toBe(expected) }) }) + +it('Does not add something if not used at all', () => { + return postcss([tailwind()]) + .process('') + .then(result => { + expect(result.css).toBe('') + }) +}) \ No newline at end of file diff --git a/src/lib/substituteResponsiveAtRules.js b/src/lib/substituteResponsiveAtRules.js index 98b306c3f..9e69e9aba 100644 --- a/src/lib/substituteResponsiveAtRules.js +++ b/src/lib/substituteResponsiveAtRules.js @@ -29,7 +29,11 @@ export default function(config) { return cloned }) ) - css.append(mediaQuery) + + if(mediaQuery.nodes.length) { + // do not add media query without any rules or comments + css.append(mediaQuery) + } }) } } From 30eb373e2b290006d612ee54dfd508b8a939cdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Heller=20=F0=9F=92=A9?= Date: Fri, 3 Nov 2017 21:46:19 +0100 Subject: [PATCH 2/5] better name for test --- __tests__/sanity.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/sanity.test.js b/__tests__/sanity.test.js index d79bcee57..979c09b02 100644 --- a/__tests__/sanity.test.js +++ b/__tests__/sanity.test.js @@ -18,7 +18,7 @@ it('generates the right CSS', () => { }) }) -it('Does not add something if not used at all', () => { +it('Do not change css if tailwind is not used at all', () => { return postcss([tailwind()]) .process('') .then(result => { From 5626feb2125f9833d85f9562a1e944cc63d21f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Heller=20=F0=9F=92=A9?= Date: Fri, 3 Nov 2017 23:09:59 +0100 Subject: [PATCH 3/5] add newline --- __tests__/sanity.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/sanity.test.js b/__tests__/sanity.test.js index 979c09b02..007f5c79a 100644 --- a/__tests__/sanity.test.js +++ b/__tests__/sanity.test.js @@ -24,4 +24,4 @@ it('Do not change css if tailwind is not used at all', () => { .then(result => { expect(result.css).toBe('') }) -}) \ No newline at end of file +}) From 8a42f279f6569642561ed89aed0644b7a42c24db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Heller=20=F0=9F=92=A9?= Date: Fri, 3 Nov 2017 23:10:53 +0100 Subject: [PATCH 4/5] code style and remove comment --- src/lib/substituteResponsiveAtRules.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/substituteResponsiveAtRules.js b/src/lib/substituteResponsiveAtRules.js index 9e69e9aba..9f2ec7b76 100644 --- a/src/lib/substituteResponsiveAtRules.js +++ b/src/lib/substituteResponsiveAtRules.js @@ -30,8 +30,7 @@ export default function(config) { }) ) - if(mediaQuery.nodes.length) { - // do not add media query without any rules or comments + if (mediaQuery.nodes.length) { css.append(mediaQuery) } }) From 004fa09435e6561143be64ea4721b0fadbe33e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Heller=20=F0=9F=92=A9?= Date: Fri, 3 Nov 2017 23:11:44 +0100 Subject: [PATCH 5/5] rename test --- __tests__/sanity.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/sanity.test.js b/__tests__/sanity.test.js index 007f5c79a..d452f6257 100644 --- a/__tests__/sanity.test.js +++ b/__tests__/sanity.test.js @@ -18,7 +18,7 @@ it('generates the right CSS', () => { }) }) -it('Do not change css if tailwind is not used at all', () => { +it('does not add any CSS if no Tailwind features are used', () => { return postcss([tailwind()]) .process('') .then(result => {