-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from styled-components/minify-css
Minify css
- Loading branch information
Showing
24 changed files
with
186 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as t from 'babel-types' | ||
|
||
export default (teplateLiteral) => { | ||
for (let element of teplateLiteral.quasis) { | ||
element.value.raw = element.value.raw.replace(/(\\r|\\n|\r|\n)\s*/g, '') | ||
element.value.cooked = element.value.cooked.replace(/[\r\n]\s*/g, '') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import styled from "styled-components"; | ||
|
||
const Test = styled.div` color: red;`; | ||
const Test = styled.div`color: red;`; | ||
styled.div``; | ||
export default styled.button``; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
const Test = s.div` width: 100%;`; | ||
const Test = s.div`width: 100%;`; | ||
import { default as s, css } from 'styled-components'; |
11 changes: 11 additions & 0 deletions
11
test/fixtures/08-minify-css-to-use-with-transpilation/.babelrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
], | ||
"plugins": [ | ||
["../../../src", { | ||
"ssr": false, | ||
"displayName": false | ||
}] | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
test/fixtures/08-minify-css-to-use-with-transpilation/after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
var _templateObject = _taggedTemplateLiteral(['width: 100%;'], ['width: 100%;']), | ||
_templateObject2 = _taggedTemplateLiteral(['content: " ', ' ";'], ['content: " ', ' ";']), | ||
_templateObject3 = _taggedTemplateLiteral(['content: " ', ' ";color: red;'], ['content: " ', ' ";color: red;']), | ||
_templateObject4 = _taggedTemplateLiteral(['&:hover {color: blue;}'], ['&:hover {color: blue;}']); | ||
|
||
var _styledComponents = require('styled-components'); | ||
|
||
var _styledComponents2 = _interopRequireDefault(_styledComponents); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } | ||
|
||
var Simple = _styledComponents2.default.div(_templateObject); | ||
|
||
var Interpolation = _styledComponents2.default.div(_templateObject2, function (props) { | ||
return props.text; | ||
}); | ||
|
||
var SpecialCharacters = _styledComponents2.default.div(_templateObject3, function (props) { | ||
return props.text; | ||
}); | ||
|
||
var Parens = _styledComponents2.default.div(_templateObject4); |
19 changes: 19 additions & 0 deletions
19
test/fixtures/08-minify-css-to-use-with-transpilation/before.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import styled from 'styled-components'; | ||
|
||
const Simple = styled.div` | ||
width: 100%; | ||
`; | ||
|
||
const Interpolation = styled.div` | ||
content: " ${props => props.text} "; | ||
`; | ||
|
||
const SpecialCharacters = styled.div` | ||
content: " ${props => props.text} ";\n color: red; | ||
`; | ||
|
||
const Parens = styled.div` | ||
&:hover { | ||
color: blue; | ||
} | ||
`; |
8 changes: 8 additions & 0 deletions
8
test/fixtures/09-minify-css-to-use-without-transpilation/.babelrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
["../../../src", { | ||
"ssr": false, | ||
"displayName": false | ||
}] | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
test/fixtures/09-minify-css-to-use-without-transpilation/after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import styled from 'styled-components'; | ||
|
||
const Simple = styled.div`width: 100%;`; | ||
|
||
const Interpolation = styled.div`content: " ${ props => props.text } ";`; | ||
|
||
const SpecialCharacters = styled.div`content: " ${ props => props.text } ";color: red;`; | ||
|
||
const Parens = styled.div`&:hover {color: blue;}color: red;`; |
20 changes: 20 additions & 0 deletions
20
test/fixtures/09-minify-css-to-use-without-transpilation/before.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import styled from 'styled-components'; | ||
|
||
const Simple = styled.div` | ||
width: 100%; | ||
`; | ||
|
||
const Interpolation = styled.div` | ||
content: " ${props => props.text} "; | ||
`; | ||
|
||
const SpecialCharacters = styled.div` | ||
content: " ${props => props.text} ";\n color: red; | ||
`; | ||
|
||
const Parens = styled.div` | ||
&:hover { | ||
color: blue; | ||
} | ||
color: red; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
["../../../src", { | ||
"ssr": false, | ||
"displayName": false | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { css, keyframes } from 'styled-components'; | ||
|
||
const key = keyframes`to {transform: rotate(360deg);}`; | ||
|
||
const color = css`color: ${ theColor };`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { css, keyframes } from 'styled-components'; | ||
|
||
const key = keyframes` | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
`; | ||
|
||
const color = css` | ||
color: ${theColor}; | ||
`; |