@@ -50,25 +50,29 @@ if (args.h || args.help || args._.length > 1) {
5050 const settingsFile = args . s || path . join ( __dirname , '..' , 'settings.json' ) ;
5151 const outputFile = 'queries.json' ;
5252 compileSettings ( queryDir , settingsFile , outputFile ) ;
53-
53+
5454 // Compile Web version
5555 const destinationPath = args . d || 'build' ;
5656 const mode = args . m || 'production' ;
5757 const baseURL = args . b || 'https://query.linkeddatafragments.org/' ;
5858 const webpackConfig = require ( args . w ? path . resolve ( process . cwd ( ) , args . w ) : '../webpack.config.js' ) ;
5959
60+ // Remove the location of queries.json which shouldn't be present in the build configuration.
61+ webpackConfig [ 0 ] . entry = webpackConfig [ 0 ] . entry . filter ( x => ! x . endsWith ( 'queries.json' ) ) ;
62+
6063 // Override the baseURL in the webpack config
6164 webpackConfig . baseURL . replace = baseURL ;
62-
65+
6366 // Override the buildContext in the webpack config
6467 webpackConfig . buildContext . dir = destinationPath ;
65-
68+
6669 for ( const entry of webpackConfig ) {
6770 entry . mode = mode ;
6871 if ( entry . output ) {
6972 entry . output . path = path . resolve ( process . cwd ( ) , destinationPath ) ;
7073 }
7174 }
75+
7276 webpack ( webpackConfig , ( err , stats ) => {
7377 if ( err ) {
7478 console . error ( err . stack || err ) ;
@@ -77,14 +81,15 @@ if (args.h || args.help || args._.length > 1) {
7781 }
7882 process . exit ( 1 ) ;
7983 }
80-
84+
8185 console . error ( stats . toString ( { colors : true } ) ) ;
8286 if ( stats . hasErrors ( ) ) {
8387 process . exit ( 1 ) ;
8488 }
85-
89+
8690 fs . unlinkSync ( '.tmp-comunica-engine.js' ) ;
8791 } ) ;
92+
8893 if ( fs . existsSync ( path . join ( process . cwd ( ) , 'queries.json' ) ) ) {
8994 fs . renameSync ( path . join ( process . cwd ( ) , 'queries.json' ) , path . join ( process . cwd ( ) , `${ destinationPath } /queries.json` ) ) ;
9095 } ;
0 commit comments