Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make yarn-run-dev not move queries.json to build folder #162

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ if (args.h || args.help || args._.length > 1) {
const baseURL = args.b || 'https://query.linkeddatafragments.org/';
const webpackConfig = require(args.w ? path.resolve(process.cwd(), args.w) : '../webpack.config.js');

// Remove the location of queries.json which shouldn't be present in the build configuration.
webpackConfig[0].entry=webpackConfig[0].entry.filter(x => !x.endsWith('queries.json'));

// Override the baseURL in the webpack config
webpackConfig.baseURL.replace = baseURL;

Expand All @@ -69,6 +72,7 @@ if (args.h || args.help || args._.length > 1) {
entry.output.path = path.resolve(process.cwd(), destinationPath);
}
}

webpack(webpackConfig, (err, stats) => {
if (err) {
console.error(err.stack || err);
Expand All @@ -85,4 +89,8 @@ if (args.h || args.help || args._.length > 1) {

fs.unlinkSync('.tmp-comunica-engine.js');
});

if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) {
fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`));
};
})();
25 changes: 0 additions & 25 deletions plugins/MoveFilePlugin.js

This file was deleted.

7 changes: 1 addition & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path');
const webpack = require('webpack');
const MoveFilePlugin = require('./plugins/MoveFilePlugin');

// First check if we can load Comunica form cwd, if not, fallback to the default
let pathToComunica;
Expand Down Expand Up @@ -48,6 +47,7 @@ module.exports = [
path.join(__dirname, './images/sparql.png'),
path.join(__dirname, './favicon.ico'),
path.join(__dirname, './solid-client-id.jsonld'),
path.join(__dirname, './queries.json'),
],
output: {
filename: 'scripts/ldf-client-ui.min.js',
Expand All @@ -59,11 +59,6 @@ module.exports = [
jQuery: path.join(__dirname, '/deps/jquery-2.1.0.js'),
}),
new webpack.NormalModuleReplacementPlugin(/^comunica-packagejson$/, (process.platform === 'win32' ? '' : '!!json-loader!') + path.join(pathToComunica, '../../package.json')),
// Include the generated queries.json file by moving it from the current working directory (where it was generated) to the build path.
new MoveFilePlugin(
() => path.join(process.cwd(), 'queries.json'),
() => path.join(__dirname, `${buildContext.dir}/queries.json`)
),
],
module: {
rules: [
Expand Down
Loading