11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
3+ const MoveFilePlugin = require ( './plugins/MoveFilePlugin' ) ;
34
45// First check if we can load Comunica form cwd, if not, fallback to the default
56let pathToComunica ;
@@ -13,7 +14,7 @@ catch {
1314 comunicaOverride = false ;
1415}
1516
16- // Make this an object so we can mutate it from the top level of the config
17+ // Make this an object, so we can mutate it from the top level of the config
1718// and have the options propagated to the plugins
1819const baseURL = {
1920 search : '<%= baseURL %>' ,
@@ -23,6 +24,12 @@ const baseURL = {
2324 flags : 'g'
2425}
2526
27+ // Make this an object, so we can mutate it from the top level of the config
28+ // and have the options propagated to the plugins
29+ const buildContext = {
30+ dir : 'build' ,
31+ }
32+
2633module . exports = [
2734 {
2835 entry : [
@@ -41,7 +48,6 @@ module.exports = [
4148 path . join ( __dirname , './images/sparql.png' ) ,
4249 path . join ( __dirname , './favicon.ico' ) ,
4350 path . join ( __dirname , './solid-client-id.jsonld' ) ,
44- path . join ( process . cwd ( ) , './queries.json' ) ,
4551 ] ,
4652 output : {
4753 filename : 'scripts/ldf-client-ui.min.js' ,
@@ -53,6 +59,11 @@ module.exports = [
5359 jQuery : path . join ( __dirname , '/deps/jquery-2.1.0.js' ) ,
5460 } ) ,
5561 new webpack . NormalModuleReplacementPlugin ( / ^ c o m u n i c a - p a c k a g e j s o n $ / , ( process . platform === 'win32' ? '' : '!!json-loader!' ) + path . join ( pathToComunica , '../../package.json' ) ) ,
62+ // Include the generated queries.json file by moving it from the current working directory (where it was generated) to the build path.
63+ new MoveFilePlugin (
64+ ( ) => path . join ( process . cwd ( ) , 'queries.json' ) ,
65+ ( ) => path . join ( __dirname , `${ buildContext . dir } /queries.json` )
66+ ) ,
5667 ] ,
5768 module : {
5869 rules : [
@@ -155,6 +166,6 @@ module.exports = [
155166 } ,
156167] ;
157168
158- // Export the baseURL object so we can mutated it
159- // in the generate script
169+ // Export the baseURL and buildContext objects, so we can mutate it in the generate script
160170module . exports . baseURL = baseURL ;
171+ module . exports . buildContext = buildContext ;
0 commit comments