Using grunt to update base href

放肆的年华 提交于 2019-12-12 20:19:44

问题


During the build process of an angular app, I would like to update the <base href="/app-dev/"> tag to <base href="/app/"> inside index.html

Is there a way to update this tag with usemin (for now, I use it to update the links to the js and css)? If not, what grunt task should I use to do that?


回答1:


I used grunt-processhtml too like so

in your say index.html file

<!-- build:[href]:build /path/you/want/ -->
<base href="/~myusername/myapp/public/" />
<!-- /build -->

in your Gruntfile.js add a task config like so

processhtml: {
    options: {
        //
    },
    build: {
        files: {
            'dist/index.html':['public/index.html']
        }
    }
}

and install the npm package of course!

npm install grunt-processhtml --save-dev


来源:https://stackoverflow.com/questions/21162992/using-grunt-to-update-base-href

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!