我有一个 Polymer 1.0 项目,我想对其进行硫化以进行生产。我使用 Gulpgulp-vulcanize
来做到这一点。
我的gulpfile.js
文件:
var gulp = require('gulp');
var Vulcanize = require('gulp-vulcanize');
gulp.task('vulcanize', function () {
return gulp.src('./src/app.html')
.pipe(Vulcanize({
inlineCss: true
}))
.pipe(gulp.dest('./dist'));
});
的内容src/app.html
如下:
<!-- Polymer elements -->
<link rel="import" href="../bower_components/google-map/google-map.html" />
<link rel="import" href="../bower_components/iron-icons/iron-icons.html" />
<link rel="import" href="../bower_components/paper-button/paper-button.html" />
<link rel="import" href="../bower_components/paper-drawer-panel/paper-drawer-panel.html" />
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html" />
<link rel="import" href="../bower_components/paper-item/paper-item.html" />
<link rel="import" href="../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../bower_components/paper-menu/paper-menu.html" />
<link rel="import" href="../bower_components/paper-progress/paper-progress.html" />
<link rel="import" href="../bower_components/paper-scroll-header-panel/paper-scroll-header-panel.html" />
<link rel="import" href="../bower_components/paper-toast/paper-toast.html" />
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html" />
问题:该过程没有完成也没有产生错误。
运行时的 CMD 输出gulp vulcanize
:
C:\Stuff\myApp>gulp vulcanize
[15:45:06] Using gulpfile C:\Stuff\myApp\gulpfile.js
[15:45:06] Starting 'vulcanize'...
C:\Stuff\myApp>
但是,当我设置为. 这种情况下的 CMD 输出为:inlineCss
false
C:\Stuff\myApp>gulp vulcanize
[15:44:55] Using gulpfile C:\Stuff\myApp\gulpfile.js
[15:44:55] Starting 'vulcanize'...
[15:44:55] Finished 'vulcanize' after 581 ms
C:\Stuff\myApp>
但是,很明显,CSS不是内联的。
编辑:
我现在已将 vulcanize 作为独立工具运行并收到此错误:
{ [Error: ENOENT, open 'C:\Stuff\myApp\wer_components\paper-drawer-panel\paper-drawer-panel.css']
errno: 34,
code: 'ENOENT',
path: 'C:\\Stuff\\myApp\\wer_components\\paper-drawer-panel\\paper-drawer-panel.css' }
Error: ENOENT, open 'C:\Stuff\myApp\wer_components\paper-drawer-panel\paper-drawer-panel.css'
请注意,它尝试访问C:\Stuff\myApp\wer_components
文件夹而不是C:\Stuff\myApp\bower_components
. 不知何故,它在文件夹名称中丢失bo
了,但我似乎无法弄清楚如何。