Gruntjs 使用grunt将字符串添加到文件路由

Gruntjs 使用grunt将字符串添加到文件路由,gruntjs,yeoman,yeoman-generator-angular,Gruntjs,Yeoman,Yeoman Generator Angular,我正在构建angularJS,需要向所有源路径添加一个字符串,如下所示: <script src="{{STATIC_URL}}scripts/scripts.65cfde8a.js"></script> 有没有一种方法可以使用grunt任务来实现这一点 我用的是约曼 提前感谢您的帮助 检查这个。您可以使用grunt或module来完成此操作。检查此项。您可以通过使用grunt或使用模块来实现这一点。我使用 我安装了grunt replace并将其添加到gruntf

我正在构建angularJS,需要向所有源路径添加一个字符串,如下所示:

<script src="{{STATIC_URL}}scripts/scripts.65cfde8a.js"></script>

有没有一种方法可以使用grunt任务来实现这一点

我用的是约曼

提前感谢您的帮助

检查这个。您可以使用grunt或module来完成此操作。

检查此项。您可以通过使用grunt或使用模块来实现这一点。

我使用

我安装了grunt replace并将其添加到gruntfile中

    replace: {
        dist: {
            options: {
                patterns: [
                    {
                        match: /src="scripts/g,
                        replacement: 'src="{{STATIC_URL}}scripts'
                    },
                    {
                        match: /href="styles/g,
                        replacement: 'href="{{STATIC_URL}}styles'
                    }
                ]
            },
            files: [
                {
                    expand: true, 
                    flatten: true, 
                    src: [
                        '<%= yeoman.dist %>/index.html',
                    ],
                    dest: '<%= yeoman.dist %>'
                }
            ]
        }
    }
替换:{
地区:{
选项:{
模式:[
{
匹配:/src=“脚本/g,
替换:“src=“{STATIC_URL}}脚本”
},
{
匹配:/href=“样式/g,
替换:'href=“{STATIC_URL}}样式”
}
]
},
档案:[
{
是的,
扁平化:是的,
src:[
“/index.html”,
],
目标:“”
}
]
}
}
我用

我安装了grunt replace并将其添加到gruntfile中

    replace: {
        dist: {
            options: {
                patterns: [
                    {
                        match: /src="scripts/g,
                        replacement: 'src="{{STATIC_URL}}scripts'
                    },
                    {
                        match: /href="styles/g,
                        replacement: 'href="{{STATIC_URL}}styles'
                    }
                ]
            },
            files: [
                {
                    expand: true, 
                    flatten: true, 
                    src: [
                        '<%= yeoman.dist %>/index.html',
                    ],
                    dest: '<%= yeoman.dist %>'
                }
            ]
        }
    }
替换:{
地区:{
选项:{
模式:[
{
匹配:/src=“脚本/g,
替换:“src=“{STATIC_URL}}脚本”
},
{
匹配:/href=“样式/g,
替换:'href=“{STATIC_URL}}样式”
}
]
},
档案:[
{
是的,
扁平化:是的,
src:[
“/index.html”,
],
目标:“”
}
]
}
}