@@ -38,12 +38,11 @@ async function main() {
3838 const srcDir = path . join ( packageRoot , 'src' ) ;
3939 const distDir = path . join ( packageRoot , 'dist' ) ;
4040
41-
4241 if ( ! fs . existsSync ( srcDir ) ) {
4342 console . error ( `The package directory "${ packageRoot } " does not contain a "src" directory.` ) ;
4443 process . exit ( 1 ) ;
4544 }
46-
45+
4746 if ( fs . existsSync ( distDir ) ) {
4847 console . log ( `Cleaning up the "${ distDir } " directory...` ) ;
4948 await fs . promises . rm ( distDir , { recursive : true } ) ;
@@ -53,41 +52,42 @@ async function main() {
5352 const inputScriptFiles = [
5453 ...glob . sync ( path . join ( srcDir , '*controller.ts' ) ) ,
5554 ...( [ '@symfony/ux-react' , '@symfony/ux-vue' , '@symfony/ux-svelte' ] . includes ( packageName )
56- ? [
57- path . join ( srcDir , 'loader.ts' ) ,
58- path . join ( srcDir , 'components.ts' ) ,
59- ]
55+ ? [ path . join ( srcDir , 'loader.ts' ) , path . join ( srcDir , 'components.ts' ) ]
6056 : [ ] ) ,
6157 ...( packageName === '@symfony/stimulus-bundle'
62- ? [
63- path . join ( srcDir , 'loader.ts' ) ,
64- path . join ( srcDir , 'controllers.ts' ) ,
65- ] : [ ] ) ,
58+ ? [ path . join ( srcDir , 'loader.ts' ) , path . join ( srcDir , 'controllers.ts' ) ]
59+ : [ ] ) ,
6660 ] ;
67-
68- const inputStyleFile = packageData . config && packageData . config . css_source ;
61+
62+ const inputStyleFile = packageData . config ? .css_source ;
6963 const buildCss = async ( ) => {
70- const inputStyleFileDist = inputStyleFile ? path . resolve ( distDir , `${ path . basename ( inputStyleFile , '.css' ) } .min.css` ) : undefined ;
64+ const inputStyleFileDist = inputStyleFile
65+ ? path . resolve ( distDir , `${ path . basename ( inputStyleFile , '.css' ) } .min.css` )
66+ : undefined ;
7167 if ( ! inputStyleFile ) {
7268 return ;
7369 }
74-
70+
7571 console . log ( 'Minifying CSS...' ) ;
7672 const css = await fs . promises . readFile ( inputStyleFile , 'utf-8' ) ;
7773 const minified = new CleanCSS ( ) . minify ( css ) . styles ;
7874 await fs . promises . writeFile ( inputStyleFileDist , minified ) ;
79- }
75+ } ;
8076
8177 if ( inputScriptFiles . length === 0 ) {
82- console . error ( `No input files found for package "${ packageName } " (directory "${ packageRoot } ").\nEnsure you have at least a file matching the pattern "src/*_controller.ts", or manually specify input files in "${ __filename } " file.` ) ;
78+ console . error (
79+ `No input files found for package "${ packageName } " (directory "${ packageRoot } ").\nEnsure you have at least a file matching the pattern "src/*_controller.ts", or manually specify input files in "${ __filename } " file.`
80+ ) ;
8381 process . exit ( 1 ) ;
8482 }
8583
8684 const rollupConfig = getRollupConfiguration ( { packageRoot, inputFiles : inputScriptFiles } ) ;
8785
8886 if ( args . values . watch ) {
89- console . log ( `Watching for JavaScript${ inputStyleFile ? ' and CSS' : '' } files modifications in "${ srcDir } " directory...` ) ;
90-
87+ console . log (
88+ `Watching for JavaScript${ inputStyleFile ? ' and CSS' : '' } files modifications in "${ srcDir } " directory...`
89+ ) ;
90+
9191 if ( inputStyleFile ) {
9292 rollupConfig . plugins = ( rollupConfig . plugins || [ ] ) . concat ( {
9393 name : 'watcher' ,
@@ -96,7 +96,7 @@ async function main() {
9696 } ,
9797 } ) ;
9898 }
99-
99+
100100 const watcher = rollup . watch ( rollupConfig ) ;
101101 watcher . on ( 'event' , ( { result } ) => {
102102 if ( result ) {
@@ -105,7 +105,7 @@ async function main() {
105105 } ) ;
106106 watcher . on ( 'change' , async ( id , { event } ) => {
107107 if ( event === 'update' ) {
108- console . log ( ` Files were modified, rebuilding...` ) ;
108+ console . log ( ' Files were modified, rebuilding...' ) ;
109109 }
110110
111111 if ( inputStyleFile && id === inputStyleFile ) {
@@ -115,12 +115,12 @@ async function main() {
115115 } else {
116116 console . log ( `Building JavaScript files from ${ packageName } package...` ) ;
117117 const start = Date . now ( ) ;
118-
118+
119119 const bundle = await rollup . rollup ( rollupConfig ) ;
120120 await bundle . write ( rollupConfig . output ) ;
121-
121+
122122 await buildCss ( ) ;
123-
123+
124124 console . log ( `Done in ${ ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 3 ) } seconds.` ) ;
125125 }
126126}
0 commit comments