Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unknown browser query dead with CRA #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const getPlugins = function (options) {
module.exports = function tachyonsBuild (css, options) {
const plugins = getPlugins(options)

if (options && !options.hasOwnProperty('from')) options.from = undefined
options = options || {from: undefined}

return postcss(plugins).process(css, options)
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"keywords": [],
"license": "MIT",
"dependencies": {
"autoprefixer": "^8.1.0",
"autoprefixer": "9.6.5",
"css-mqpacker": "^6.0.2",
"cssnano": "^3.10.0",
"cssnano": "4.1.10",
"perfectionist": "^2.4.0",
"postcss": "^6.0.19",
"postcss-calc": "^6.0.1",
Expand Down
165 changes: 165 additions & 0 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`processes source code 1`] = `
"/*
BACKGROUND SIZE
Base:
bg = background-size
Modifiers:
cv = cover
cn = contain
Media Query Extensions:
-ns = not-small
-m = medium
-l = large
*/
.bg-cv { background-size: cover; }
.bg-cn { background-size: contain; }
.grow:hover, .grow:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
.foo { background-size: cover; }
.foo:hover, .foo:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
@media screen and (min-width: 30em) {
.bg-cv-ns { background-size: cover; }
.bg-cn-ns { background-size: contain; }
}
@media screen and (min-width: 30em) and (max-width: 60em) {
.bg-cv-m { background-size: cover; }
.bg-cn-m { background-size: contain; }
}
@media screen and (min-width: 60em) {
.bg-cv-l { background-size: cover; }
.bg-cn-l { background-size: contain; }
}
"
`;

exports[`processes source code and minifies css 1`] = `".bg-cv{background-size:cover}.bg-cn{background-size:contain}.grow:focus,.grow:hover{-webkit-transform:scale(1.05);transform:scale(1.05)}.foo{background-size:cover}.foo:focus,.foo:hover{-webkit-transform:scale(1.05);transform:scale(1.05)}@media screen and (min-width:30em){.bg-cv-ns{background-size:cover}.bg-cn-ns{background-size:contain}}@media screen and (min-width:30em) and (max-width:60em){.bg-cv-m{background-size:cover}.bg-cn-m{background-size:contain}}@media screen and (min-width:60em){.bg-cv-l{background-size:cover}.bg-cn-l{background-size:contain}}"`;

exports[`processes source code and repeats classes 1`] = `
"/*
BACKGROUND SIZE
Base:
bg = background-size
Modifiers:
cv = cover
cn = contain
Media Query Extensions:
-ns = not-small
-m = medium
-l = large
*/
.bg-cv.bg-cv.bg-cv.bg-cv { background-size: cover; }
.bg-cn.bg-cn.bg-cn.bg-cn { background-size: contain; }
.grow.grow.grow.grow:hover, .grow.grow.grow.grow:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
.foo.foo.foo.foo { background-size: cover; }
.foo.foo.foo.foo:hover, .foo.foo.foo.foo:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
@media screen and (min-width: 30em) {
.bg-cv-ns.bg-cv-ns.bg-cv-ns.bg-cv-ns { background-size: cover; }
.bg-cn-ns.bg-cn-ns.bg-cn-ns.bg-cn-ns { background-size: contain; }
}
@media screen and (min-width: 30em) and (max-width: 60em) {
.bg-cv-m.bg-cv-m.bg-cv-m.bg-cv-m { background-size: cover; }
.bg-cn-m.bg-cn-m.bg-cn-m.bg-cn-m { background-size: contain; }
}
@media screen and (min-width: 60em) {
.bg-cv-l.bg-cv-l.bg-cv-l.bg-cv-l { background-size: cover; }
.bg-cn-l.bg-cn-l.bg-cn-l.bg-cn-l { background-size: contain; }
}
"
`;

exports[`processes source code with custom plugins 1`] = `
"/*
BACKGROUND SIZE
Base:
bg = background-size
Modifiers:
cv = cover
cn = contain
Media Query Extensions:
-ns = not-small
-m = medium
-l = large
*/
.bg-cv { background-size: cover; }
.bg-cn { background-size: contain; }
.grow:hover, .grow:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
.foo { background-size: cover; }
.foo:hover, .foo:focus { -webkit-transform: scale( 1.05 ); transform: scale( 1.05 ); }
@media screen and (min-width: 30em) {
.bg-cv-ns { background-size: cover; }
.bg-cn-ns { background-size: contain; }
}
@media screen and (min-width: 30em) and (max-width: 60em) {
.bg-cv-m { background-size: cover; }
.bg-cn-m { background-size: contain; }
}
@media screen and (min-width: 60em) {
.bg-cv-l { background-size: cover; }
.bg-cn-l { background-size: contain; }
}
"
`;

exports[`processes source code with optional rtl support 1`] = `
"/* Media Query Variables */
/*

FLOATS

1. Floated elements are automatically rendered as block level elements.
Setting floats to display inline will fix the double margin bug in
ie6. You know... just in case.

2. Don't forget to clearfix your floats with .cf

Base:
f = float

Modifiers:
l = left
r = right
n = none

Media Query Extensions:
-ns = not-small
-m = medium
-l = large

*/
.fl { _display: inline; }
[dir=ltr] .fl { float: left; }
[dir=rtl] .fl { float: right; }
.fr { _display: inline; }
[dir=ltr] .fr { float: right; }
[dir=rtl] .fr { float: left; }
[dir] .fn { float: none; }
@media screen and (min-width: 30em) {
.fl-ns { _display: inline; }
[dir=ltr] .fl-ns { float: left; }
[dir=rtl] .fl-ns { float: right; }
.fr-ns { _display: inline; }
[dir=ltr] .fr-ns { float: right; }
[dir=rtl] .fr-ns { float: left; }
[dir] .fn-ns { float: none; }
}
@media screen and (min-width: 30em) and (max-width: 60em) {
.fl-m { _display: inline; }
[dir=ltr] .fl-m { float: left; }
[dir=rtl] .fl-m { float: right; }
.fr-m { _display: inline; }
[dir=ltr] .fr-m { float: right; }
[dir=rtl] .fr-m { float: left; }
[dir] .fn-m { float: none; }
}
@media screen and (min-width: 60em) {
.fl-l { _display: inline; }
[dir=ltr] .fl-l { float: left; }
[dir=rtl] .fl-l { float: right; }
.fr-l { _display: inline; }
[dir=ltr] .fr-l { float: right; }
[dir=rtl] .fr-l { float: left; }
[dir] .fn-l { float: none; }
}
"
`;
1 change: 0 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const tachyonsBuildCss = require('../')
const { getPlugins } = require('../')

const input = fs.readFileSync('test/fixtures/input.css', 'utf8')
const inputColorFunction = fs.readFileSync('test/fixtures/input_color_function.css', 'utf8')

test('processes source code', async t => {
const result = await tachyonsBuildCss(input)
Expand Down
Loading