0

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?

4

1 回答 1

1

不幸的是,在使用 lite-server 时,无法扩展dev脚本package.json以执行内联配置。

如果您不想在项目的根目录中放置配置文件,您只需将其放在项目的其他位置(即,在名为 的文件夹中)并通过或运行时选项configs提供配置文件的自定义路径。所以你的脚本将是.-c--configdev"lite-server -c configs/bs-config.json"

查看这个 GitHub 问题:不再支持命令行参数?

于 2016-07-20T17:43:26.103 回答