我正在尝试将 usemin 与多个客户端 html 文件一起使用。我正在通过 for 循环添加每个客户端的 usemin 功能。
我得到了以下 HTML 和 CSS 方法来工作:
initConfig.usemin[key+'-html'] = {
options: {
assetsDirs : [
clients[key].dist,
clients[key].dist+'/assets/images',
clients['shared'].dist,
clients['shared'].dist+'/assets/images'
],
type:'html',
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
},
files: {
src: [
clients[key].dist+'/{,*/}*.html'
]
}
};
initConfig.usemin[key+'-css'] = {
options: {
assetsDirs : [
clients[key].dist,
clients[key].dist+'/assets/images',
clients['shared'].dist,
clients['shared'].dist+'/assets/images'
],
type:'css',
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
},
files: {
src: [
clients[key].dist+'/{,*/}*.css'
]
}
};
不幸的是,我无法让这个 JS 工作:
initConfig.usemin[key+'-js'] = {
options: {
assetsDirs : [
clients[key].dist,
clients[key].dist+'/assets/images'
],
type:'js',
patterns: {
js: [
[/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
]
}
},
files: {
src: [
clients[key].dist+'/{,*/}*.js'
]
}
};
我收到以下错误:
Warning: Unsupported pattern: js Use --force to continue.
有任何想法吗?
我已经测试过这里提到的解决方案适用于一个客户端,但是我使用多个客户端和他们自己的 index.html 文件并得到上面提到的相同错误: