Search code examples
angularjsjsonnpmbrowser-synclite-server

Lite server without config file


I'm using lite server for developing my Angular projects. It depends on and uses BrowserSync to do most of the work (serving the site to localhost, live reload etc).

Currently, I have a config file bs-config.json in my root for this module:

{ 
  "injectChanges": true,
  "files": ["./**/*.{html,css,js,png,jpg,svg,gif}"],
  "watchOptions": { 
    "ignored": [
      "node_modules",
      "src/**/*.*",
      "app/**/*.js"
    ]
  }
}

Then in my package.json I have a script to execute it, referring to the config file:

{
  "version": "1.0.0",
  "scripts": {
    "dev": "lite-server -c bs-config.json"
  },
  "devDependencies": {
    "lite-server": "~2.2.0"
  }
}

Works great. But ideally I don't want a config file in the root of my project that isn't used in production. Is it possibly to extend the script in my package.json to execute the config inline with the command?


Solution

  • Unfortunately, its not possible to extend the dev script in your package.json to execute the config inline when using lite-server.

    If you don't want a config file in the root of your project, you would simply place it elsewhere in your project (i.e., in a folder called configs) and provide a custom path to your config file via -c or --config run time options. So your dev script will be "lite-server -c configs/bs-config.json".

    Check out this GitHub issue: Command line arguments no longer supported?