File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ function getScopedNameGenerator(opts) {
21
21
const scopedNameGenerator = opts . generateScopedName || generateScopedName ;
22
22
23
23
if ( typeof scopedNameGenerator === "function" ) return scopedNameGenerator ;
24
- return genericNames ( scopedNameGenerator , { context : process . cwd ( ) } ) ;
24
+ return genericNames ( scopedNameGenerator , {
25
+ context : process . cwd ( ) ,
26
+ hashPrefix : opts . hashPrefix
27
+ } ) ;
25
28
}
26
29
27
30
function getLoader ( opts , plugins ) {
Original file line number Diff line number Diff line change @@ -112,6 +112,24 @@ it("processes camelCase option", async () => {
112
112
} ) ;
113
113
} ) ;
114
114
115
+ it ( "processes hashPrefix option" , async ( ) => {
116
+ const generateScopedName = "[hash:base64:5]" ;
117
+ const hashPrefix = "prefix" ;
118
+ const getJSON = ( ) => { } ;
119
+
120
+ const withoutHashPrefix = plugin ( { generateScopedName, getJSON } ) ;
121
+ const withHashPrefix = plugin ( { generateScopedName, getJSON, hashPrefix } ) ;
122
+
123
+ const css = ".foo {}" ;
124
+ const params = { from : "test.css" } ;
125
+
126
+ const result1 = await postcss ( [ withoutHashPrefix ] ) . process ( css , params ) ;
127
+ const result2 = await postcss ( [ withHashPrefix ] ) . process ( css , params ) ;
128
+
129
+ expect ( result2 . css ) . toMatchSnapshot ( "processes hashPrefix option" ) ;
130
+ expect ( result1 . css ) . not . toEqual ( result2 . css ) ;
131
+ } ) ;
132
+
115
133
it ( "different instances have different generateScopedName functions" , async ( ) => {
116
134
const one = plugin ( {
117
135
generateScopedName : ( ) => "one" ,
You can’t perform that action at this time.
0 commit comments