@@ -7,7 +7,7 @@ import fs from 'fs';
77import glob from 'glob' ;
88import module from 'module' ;
99import { dirname , join , relative } from 'path' ;
10- import sass from 'sass' ;
10+ import * as sass from 'sass' ;
1111import url from 'url' ;
1212import tsNode from 'ts-node' ;
1313
@@ -86,22 +86,26 @@ async function main() {
8686 */
8787async function compileSassFiles ( ) {
8888 const sassFiles = glob . sync ( 'src/**/!(_*|theme).scss' , { cwd : projectDir , absolute : true } ) ;
89- const sassTasks = [ ] ;
89+ const writeTasks = [ ] ;
9090
91+ let count = 0 ;
9192 for ( const file of sassFiles ) {
9293 const outRelativePath = relative ( projectDir , file ) . replace ( / \. s c s s $ / , '.css' ) ;
9394 const outPath = join ( projectDir , outRelativePath ) ;
94- const task = renderSassFileAsync ( file ) . then ( async content => {
95+ const content = renderSassFile ( file ) . css ;
96+
97+ count ++ ;
98+ console . error ( `Compiled ${ count } /${ sassFiles . length } files` ) ;
99+
100+ writeTasks . push ( async ( ) => {
95101 console . info ( 'Compiled, now writing:' , outRelativePath ) ;
96102 await fs . promises . mkdir ( dirname ( outPath ) , { recursive : true } ) ;
97103 await fs . promises . writeFile ( outPath , content ) ;
98104 } ) ;
99-
100- sassTasks . push ( task ) ;
101105 }
102106
103- // Wait for all Sass compilations to finish.
104- await Promise . all ( sassTasks ) ;
107+ // Start all writes and wait for them to finish.
108+ await Promise . all ( writeTasks . map ( task => task ( ) ) ) ;
105109}
106110
107111/**
@@ -156,14 +160,12 @@ async function createEntryPointSpecFile() {
156160 return specEntryPointFile ;
157161}
158162
159- /** Helper function to render a Sass file asynchronously using promises. */
160- async function renderSassFileAsync ( inputFile ) {
161- return sass
162- . compileAsync ( inputFile , {
163- loadPaths : [ nodeModulesDir , projectDir ] ,
164- importers : [ localPackageSassImporter ] ,
165- } )
166- . then ( result => result . css ) ;
163+ /** Helper function to render a Sass file. */
164+ function renderSassFile ( inputFile ) {
165+ return sass . compile ( inputFile , {
166+ loadPaths : [ nodeModulesDir , projectDir ] ,
167+ importers : [ localPackageSassImporter ] ,
168+ } ) ;
167169}
168170
169171/**
0 commit comments