question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Merge rewrite rules from multiple .local-web-server.json files

See original GitHub issue

If we have two .local-web-server.json files, say in the current directory and in the user’s $HOME, configurations like port get merged properly, but if both files have rewrite rules, then only the rules in the current directory show up with ws --config.

Maybe it needs a deep merge?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
75lbcommented, Mar 23, 2017

this is resolved in v2 which is in progress and available for preview. Config files are now plain javascipt, giving you freedom to share and merge options however you like.

The config file (lws.config.js by default) should look something like this:

module.exports = {
  rewrite: [
    {
      from: '/resources/*',
      to: 'http://remote-api.org:8080/resources/$1'
    }
  ],
  directory: 'src',
  'log.format': 'none'
}

An example of how you might share and merge options:

/* pull options from the env */
const remoteAPI = process.env.REMOTE_API

/* .. or an installed package */
const sharedOptions = require('shared-options')

/* merge them to taste */
const options = Object.assign({}, sharedOptions, {
  rewrite: [
    {
      from: '/resources/*',
      to: `http://${remoteAPI}/resources/$1`
    }
  ]
})

module.exports = options
1reaction
75lbcommented, Oct 18, 2016

i have released this feature on a tag as it needs testing… please install and let me know your thoughts:

$ npm install -g local-web-server@deep

then run it with this flag:

$ ws --deep-merge-config

see the config master deep branch to see the changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to merge multiple json files with same structure into one ...
Show activity on this post. I need to merge file1. json file2. json (could be more) into onefile.
Read more >
local-web-server - npm
Start using local-web-server in your project by running `npm i ... package.json ... To avoid a 404 you need a rewrite rule:.
Read more >
API - esbuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >
How to merge json files using jq or any tool?
My favorite tool for JSON and YAML merging is Spruce. ... Do a relational JOIN operation between the two files based on the...
Read more >
Deployment - Angular
To output to a different folder, change the outputPath in angular.json . ... angular.json file) with a deploy section for the selected project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found