我们正在尝试让gulp-useref与我们正在开发的 Angular2 应用程序一起工作,特别是用于构建生产应用程序的任务。
不幸的是,gulp-useref不太喜欢 html 导入,并且我不清楚是否可以创建自定义函数,因为它对父useref包进行了解释。
我已经尝试过的不同的东西: - 使用 gulp-useref-import - 使用 noconcat
有没有人试图做类似的事情?
我们的项目基于这个Starter Repo
我们正在尝试让gulp-useref与我们正在开发的 Angular2 应用程序一起工作,特别是用于构建生产应用程序的任务。
不幸的是,gulp-useref不太喜欢 html 导入,并且我不清楚是否可以创建自定义函数,因为它对父useref包进行了解释。
我已经尝试过的不同的东西: - 使用 gulp-useref-import - 使用 noconcat
有没有人试图做类似的事情?
我们的项目基于这个Starter Repo
好的,最后我已经能够让它工作,但它并不容易弄清楚。
所以这必须放在index.html中(注意我必须将 Polymer 初始化分拆到它自己的文件中)
<!-- build:js assets/webcomponents.js -->
<script src="/assets/components/webcomponentsjs/webcomponents.js"></script>
<!-- endinject -->
<!-- build:js assets/polymer.js -->
<script src="/assets/scripts/polymer.js"></script>
<!-- endinject -->
<!-- build:custom elements.html -->
<link rel="import" href="/assets/components/polymer/polymer.html">
<link rel="import" href="/assets/components/paper-button/paper-button.html">
<link rel="import" href="/assets/components/paper-input/paper-input.html">
<!-- endinject -->
这是build.js中所需的更改
gulp.src(config.assetsPath.components + '**/*.*', {
base: config.assetsPath.components
})
.pipe(gulp.dest(config.build.assetPath + 'components'));
gulp.src(config.index)
.pipe(useref({
custom: function(content, target) {
return content === '/assets/components' ? target : content;
}
}))
useref 仍然无法合并 html 文件,但现在它将保留引用而不是剥离它们