@@ -85,31 +85,35 @@ async function parseCss(
85
85
// These are the same primitive values supported by JSON
86
86
let value : CssPluginOptions [ keyof CssPluginOptions ] = decl . value
87
87
88
- if ( value === 'null' ) {
89
- value = null
90
- } else if ( value === 'true' ) {
91
- value = true
92
- } else if ( value === 'false' ) {
93
- value = false
94
- } else if ( ! Number . isNaN ( Number ( value ) ) ) {
95
- value = Number ( value )
96
- } else if (
97
- ( value [ 0 ] === '"' && value [ value . length - 1 ] === '"' ) ||
98
- ( value [ 0 ] === "'" && value [ value . length - 1 ] === "'" )
99
- ) {
100
- value = value . slice ( 1 , - 1 )
101
- } else if (
102
- ( value [ 0 ] === '[' && value [ value . length - 1 ] === ']' ) ||
103
- ( value [ 0 ] === '{' && value [ value . length - 1 ] === '}' )
104
- ) {
105
- throw new Error (
106
- `Unexpected \`@plugin\` option: Value of declaration \`${ toCss ( [ decl ] ) . trim ( ) } \` is not supported.\n\nIt looks like you want to pass an ${
107
- value [ 0 ] === '[' ? 'array' : 'object'
108
- } to plugin options. This is not supported in CSS.`,
109
- )
110
- }
88
+ let parts = segment ( value , ',' ) . map ( ( part ) => {
89
+ if ( part === 'null' ) {
90
+ return null
91
+ } else if ( part === 'true' ) {
92
+ return true
93
+ } else if ( part === 'false' ) {
94
+ return false
95
+ } else if ( ! Number . isNaN ( Number ( part ) ) ) {
96
+ return Number ( part )
97
+ } else if (
98
+ ( part [ 0 ] === '"' && part [ part . length - 1 ] === '"' ) ||
99
+ ( part [ 0 ] === "'" && part [ part . length - 1 ] === "'" )
100
+ ) {
101
+ return part . slice ( 1 , - 1 )
102
+ } else if (
103
+ ( part [ 0 ] === '[' && part [ part . length - 1 ] === ']' ) ||
104
+ ( part [ 0 ] === '{' && part [ part . length - 1 ] === '}' )
105
+ ) {
106
+ throw new Error (
107
+ `Unexpected \`@plugin\` option: Value of declaration \`${ toCss ( [ decl ] ) . trim ( ) } \` is not supported.\n\nIt looks like you want to pass an ${
108
+ part [ 0 ] === '[' ? 'array' : 'object'
109
+ } to plugin options. This is not supported in CSS.`,
110
+ )
111
+ }
112
+
113
+ return value
114
+ } )
111
115
112
- options [ decl . property ] = value
116
+ options [ decl . property ] = parts . length === 1 ? parts [ 0 ] : parts
113
117
}
114
118
115
119
pluginPaths . push ( [ pluginPath , Object . keys ( options ) . length > 0 ? options : null ] )
0 commit comments