@@ -36,6 +36,7 @@ const projectDir = resolve(_dirname, '../../../../..');
3636const srcPath = resolve ( projectDir , 'src' ) ;
3737const isSrcExists = fs . pathExistsSync ( srcPath ) ;
3838const srcDir = isSrcExists ? srcPath : resolve ( projectDir , 'components' ) ;
39+ const isDrupal = emulsifyConfig . project . platform === 'drupal' ;
3940
4041// Glob pattern for SCSS files that ignore file names prefixed with underscore.
4142const BaseScssPattern = fs . pathExistsSync ( resolve ( projectDir , 'src' ) )
@@ -131,18 +132,11 @@ function getEntries(
131132 // Component JS entries.
132133 globSync ( jsMatcher ) . forEach ( ( file ) => {
133134 if ( ! file . includes ( 'dist/' ) ) {
134- const filePath = file . split ( 'components/' ) [ 1 ] ;
135- const filePathDist = replaceLastSlash ( filePath , '/js/' ) ;
136- const distStructure = fs . pathExistsSync ( resolve ( projectDir , 'src' ) )
137- ? 'components'
138- : 'js' ;
139- const newFilePath =
140- emulsifyConfig . project . platform === 'drupal' &&
141- fs . pathExistsSync ( resolve ( projectDir , 'src' ) )
142- ? `components/${ filePathDist . replace ( '.js' , '' ) } `
143- : `dist/${ distStructure } /${
144- distStructure === 'components' ? 'components' : 'js'
145- } /${ filePathDist . replace ( '.js' , '' ) } `;
135+ const filePath = file . split ( `${ srcDir } /components/` ) [ 1 ] ;
136+ const filePathDistRaw = replaceLastSlash ( filePath , '/js/' ) ;
137+ const filePathDist = filePathDistRaw . replace ( / \. j s $ / , '' ) ;
138+ const prefix = isDrupal && isSrcExists ? 'components' : 'dist/components' ;
139+ const newFilePath = `${ prefix } /${ filePathDist } ` ;
146140 addEntry ( newFilePath , file ) ;
147141 }
148142 } ) ;
@@ -162,18 +156,11 @@ function getEntries(
162156
163157 // Component SCSS entries.
164158 globSync ( ComponentScssMatcher ) . forEach ( ( file ) => {
165- const filePath = file . split ( 'components/' ) [ 1 ] ;
166- const filePathDist = replaceLastSlash ( filePath , '/css/' ) ;
167- const distStructure = fs . pathExistsSync ( resolve ( projectDir , 'src' ) )
168- ? 'components'
169- : 'css' ;
170- const newFilePath =
171- emulsifyConfig . project . platform === 'drupal' &&
172- fs . pathExistsSync ( resolve ( projectDir , 'src' ) )
173- ? `components/${ filePathDist . replace ( '.scss' , '' ) } `
174- : `dist/${ distStructure } /${
175- distStructure === 'components' ? 'components' : 'css'
176- } /${ filePathDist . replace ( '.scss' , '' ) } `;
159+ const filePath = file . split ( `${ srcDir } /components/` ) [ 1 ] ;
160+ const filePathDistRaw = replaceLastSlash ( filePath , '/css/' ) ;
161+ const filePathDist = filePathDistRaw . replace ( / \. s c s s $ / , '' ) ;
162+ const prefix = isDrupal && isSrcExists ? 'components' : 'dist/components' ;
163+ const newFilePath = `${ prefix } /${ filePathDist } ` ;
177164 addEntry ( newFilePath , file ) ;
178165 } ) ;
179166
0 commit comments