File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ function getScopedNameGenerator(opts) {
2121 const scopedNameGenerator = opts . generateScopedName || generateScopedName ;
2222
2323 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+ } ) ;
2528}
2629
2730function getLoader ( opts , plugins ) {
Original file line number Diff line number Diff line change @@ -112,6 +112,24 @@ it("processes camelCase option", async () => {
112112 } ) ;
113113} ) ;
114114
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+
115133it ( "different instances have different generateScopedName functions" , async ( ) => {
116134 const one = plugin ( {
117135 generateScopedName : ( ) => "one" ,
You can’t perform that action at this time.
0 commit comments