Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何使用负glob模式?_Angular_Progressive Web Apps_Service Worker Config - Fatal编程技术网

Angular 如何使用负glob模式?

Angular 如何使用负glob模式?,angular,progressive-web-apps,service-worker-config,Angular,Progressive Web Apps,Service Worker Config,我们的构建生成e2015和es5捆绑包-例如,在dist dir中,我们将有如下文件: /common-es2015.7765e11579e6bbced8e8.js /common-es5.7765e11579e6bbced8e8.js /custom.js 我们希望将ngsw-config.json配置为预检索所有js文件,但名称中的es5除外 到目前为止,我们尝试的glob模式不起作用,但是当我们使用这个在线测试仪时,它们起作用 : 模式:/!(*es5)*.js 测试字符串: /comm

我们的构建生成e2015和es5捆绑包-例如,在dist dir中,我们将有如下文件:

/common-es2015.7765e11579e6bbced8e8.js
/common-es5.7765e11579e6bbced8e8.js
/custom.js
我们希望将ngsw-config.json配置为预检索所有js文件,但名称中的
es5
除外

到目前为止,我们尝试的glob模式不起作用,但是当我们使用这个在线测试仪时,它们起作用

: 模式:
/!(*es5)*.js

测试字符串:

/common-es2015.7765e11579e6bbced8e8.js
/common-es5.7765e11579e6bbced8e8.js
/custom.js
/favicon.ico 
正确选择
common-es2015*
custom.js

但是当我们在
ngsw config.json
中使用相同的模式时,它就不起作用了

{
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": ["/favicon.ico", "/index.html", "/*.css", "/!(*es5)*.js"]
      }
    },
根据负数,应该支持globs

这个模式有什么问题吗?

我找到了一个很好的解决方案

想法是首先包括所有js文件,然后排除es5文件:

{
“资产组”:[
{
“名称”:“应用程序”,
“安装模式”:“预取”,
“资源”:{
“文件”:[“/favicon.ico”、“/index.html”、“/*.css”、“/*.js”、“!/*-es5*.js”]
}
}
}
然后,我们可以为es5文件创建另一个惰性资产组:

{
“名称”:“资产”,
“installMode”:“lazy”,
“资源”:{
“文件”:[“.”、“/*-es5*.js”]
}
}