我正在使用 gulp replace 通过匹配起始和结束字符串将完整路径名替换为另一个名称
例子
输入:
src/app/Client/Home/home.service.js
输出
dist/Home/home.service.min.js
.state('masterPage.blogArticle', {
url: "/article/:postId",
templateUrl: "src/app/Client/Blog/article/index.html",
controller: "articleCtrl",
controllerAs: 'vm',
resolve: {
deps: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'competitiveClient',
insertBefore: '#ng_load_plugins_before', // load the above css files before a LINK element with this ID. Dynamic CSS files must be loaded between core and theme css files
files: [
'src/app/Client/Blog/article/article.service.js',
'src/app/Client/Blog/article/article.controller.js'
]
});
}]
}
})
在这里,我想在所有状态下用上面的输出替换 .js 文件路径
gulp.task('templates', () => {
gulp.src(['dist/client/app/js/app.config.min.js'])
.pipe(replace(/^(src\/app\/Client\/)(.*)(.js)$/g, 'dist/client/app'))
.pipe(replace(/.js/g, '.min.js'))
.pipe(gulp.dest('dist/client/app/js/'));
});
但它不起作用,它没有得到匹配的路径,所以如果有人有想法解决它。提前致谢。