Grunt 打包发布问题

index.html页面引用了 a.js b.js c.js
通过grunt打包之后生成dist/build.js
那发布的时候 index.html是不是要手动把引用a.js b.js c.js改成引用dist/build.js

现在本人解决方法是 页面直接引用压缩后的build.js 但是老是感觉怪怪的,grunt下有没有什么插件可以直接在压缩打包之后直接把页面上引用的资源replace成打包生成的路径?

阅读 3.3k
1 个回答

可以用这个插件: grunt-dom-munger
DEMO:

            index  : {
                options: {
                    remove : ['script[data-remove!="false"]', 'link[data-remove!="false"]'],
                    append : [
                        {
                            selector: 'body',
                            html    : '<script type="text/javascript" src="XXX/build.js"></script>'
                        }
                    ]
                },
                src    : 'index.html',
                dest   : 'dist/index.html'
            }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题