Skip to content

Commit 7596b8d

Browse files
authored
fix(jss-plugin-global): Support format option for @global rules (#1572)
1 parent e693eca commit 7596b8d

File tree

7 files changed

+43
-39
lines changed

7 files changed

+43
-39
lines changed

packages/css-jss/.size-snapshot.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"css-jss.js": {
3-
"bundled": 59688,
4-
"minified": 21828,
5-
"gzipped": 7357
3+
"bundled": 59702,
4+
"minified": 21830,
5+
"gzipped": 7354
66
},
77
"css-jss.min.js": {
8-
"bundled": 58613,
9-
"minified": 21205,
10-
"gzipped": 7078
8+
"bundled": 58627,
9+
"minified": 21207,
10+
"gzipped": 7075
1111
},
1212
"css-jss.cjs.js": {
1313
"bundled": 2949,

packages/jss-plugin-global/.size-snapshot.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"jss-plugin-global.js": {
3-
"bundled": 4988,
4-
"minified": 2184,
5-
"gzipped": 919
3+
"bundled": 5002,
4+
"minified": 2186,
5+
"gzipped": 914
66
},
77
"jss-plugin-global.min.js": {
8-
"bundled": 4988,
9-
"minified": 2184,
10-
"gzipped": 919
8+
"bundled": 5002,
9+
"minified": 2186,
10+
"gzipped": 914
1111
},
1212
"jss-plugin-global.cjs.js": {
13-
"bundled": 4263,
14-
"minified": 2310,
15-
"gzipped": 892
13+
"bundled": 4277,
14+
"minified": 2312,
15+
"gzipped": 886
1616
},
1717
"jss-plugin-global.esm.js": {
18-
"bundled": 3917,
19-
"minified": 2036,
20-
"gzipped": 788,
18+
"bundled": 3931,
19+
"minified": 2038,
20+
"gzipped": 783,
2121
"treeshaked": {
2222
"rollup": {
2323
"code": 55,

packages/jss-plugin-global/src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class GlobalContainerRule {
5151
/**
5252
* Generates a CSS string.
5353
*/
54-
toString() {
55-
return this.rules.toString()
54+
toString(options) {
55+
return this.rules.toString(options)
5656
}
5757
}
5858

packages/jss-plugin-global/src/index.test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import nested from 'jss-plugin-nested'
66
import global from './index'
77

88
const settings = {
9-
createGenerateId: () => (rule) => `${rule.key}-id`
9+
createGenerateId: () => rule => `${rule.key}-id`
1010
}
1111

1212
describe('jss-plugin-global', () => {
@@ -37,6 +37,10 @@ describe('jss-plugin-global', () => {
3737
it('should generate correct CSS', () => {
3838
expect(sheet.toString()).to.be('a {\n color: red;\n}\nbody {\n color: green;\n}')
3939
})
40+
41+
it('should remove whitespaces', () => {
42+
expect(sheet.toString({format: false})).to.be('a{color:red;}body{color:green;}')
43+
})
4044
})
4145

4246
describe('@global linked', () => {

packages/jss-preset-default/.size-snapshot.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"jss-preset-default.js": {
3-
"bundled": 56975,
4-
"minified": 21052,
5-
"gzipped": 7009
3+
"bundled": 56989,
4+
"minified": 21054,
5+
"gzipped": 7004
66
},
77
"jss-preset-default.min.js": {
8-
"bundled": 55900,
9-
"minified": 20429,
10-
"gzipped": 6731
8+
"bundled": 55914,
9+
"minified": 20431,
10+
"gzipped": 6726
1111
},
1212
"jss-preset-default.cjs.js": {
1313
"bundled": 2222,

packages/jss-starter-kit/.size-snapshot.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"jss-starter-kit.js": {
3-
"bundled": 73003,
4-
"minified": 31503,
5-
"gzipped": 9646
3+
"bundled": 73017,
4+
"minified": 31505,
5+
"gzipped": 9640
66
},
77
"jss-starter-kit.min.js": {
8-
"bundled": 71928,
9-
"minified": 31315,
10-
"gzipped": 9421
8+
"bundled": 71942,
9+
"minified": 31317,
10+
"gzipped": 9415
1111
},
1212
"jss-starter-kit.cjs.js": {
1313
"bundled": 5647,

packages/react-jss/.size-snapshot.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"react-jss.js": {
3-
"bundled": 135303,
4-
"minified": 49865,
5-
"gzipped": 16671
3+
"bundled": 135317,
4+
"minified": 49867,
5+
"gzipped": 16666
66
},
77
"react-jss.min.js": {
8-
"bundled": 102253,
9-
"minified": 39724,
10-
"gzipped": 13794
8+
"bundled": 102267,
9+
"minified": 39726,
10+
"gzipped": 13789
1111
},
1212
"react-jss.cjs.js": {
1313
"bundled": 21449,

0 commit comments

Comments
 (0)