@@ -50,22 +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+
66+ // Override the buildContext in the webpack config
67+ webpackConfig . buildContext . dir = destinationPath ;
68+
6369 for ( const entry of webpackConfig ) {
6470 entry . mode = mode ;
6571 if ( entry . output ) {
6672 entry . output . path = path . resolve ( process . cwd ( ) , destinationPath ) ;
6773 }
6874 }
75+
6976 webpack ( webpackConfig , ( err , stats ) => {
7077 if ( err ) {
7178 console . error ( err . stack || err ) ;
@@ -74,14 +81,15 @@ if (args.h || args.help || args._.length > 1) {
7481 }
7582 process . exit ( 1 ) ;
7683 }
77-
84+
7885 console . error ( stats . toString ( { colors : true } ) ) ;
7986 if ( stats . hasErrors ( ) ) {
8087 process . exit ( 1 ) ;
8188 }
82-
89+
8390 fs . unlinkSync ( '.tmp-comunica-engine.js' ) ;
8491 } ) ;
92+
8593 if ( fs . existsSync ( path . join ( process . cwd ( ) , 'queries.json' ) ) ) {
8694 fs . renameSync ( path . join ( process . cwd ( ) , 'queries.json' ) , path . join ( process . cwd ( ) , `${ destinationPath } /queries.json` ) ) ;
8795 } ;
0 commit comments