简体   繁体   English

Polymer 1.0 + Webpack

[英]Polymer 1.0 + Webpack

Currently I am trying to use Webpack ( http://webpack.github.io/ ) as my module builder and wanted to see if anyone has done this yet with Polymer v1.0. 目前我正在尝试使用Webpack( http://webpack.github.io/ )作为我的模块构建器,并希望看看是否有人使用Polymer v1.0完成了这项工作。 There is a webpack loader called polymer-loader ( https://www.npmjs.com/package/polymer-loader ) but it does not work with anything higher than Polymer v0.5. 有一个名为polymer-loader( https://www.npmjs.com/package/polymer-loader )的webpack加载器,但它不适用于高于Polymer v0.5的任何东西。

Unfortunately, Polymer 1.0 is presently unsupported by polymer-loader due to an API change. 不幸的是,由于API的变化,聚合物1.0目前不受polymer-loader支持。 It is possible that this may be repaired in the near future, but in the meantime you may have to resort to either a different package or builder. 这有可能在不久的将来修复,但与此同时,您可能不得不求助于不同的包装或建造者。 Hopefully a fix becomes available soon. 希望很快就能获得修复。

I make a simple solution with polymer-ext 我使用polymer-ext制作一个简单的解决方案

var PolymerExt = require('polymer-ext')

var t = require('raw!./test.tmpl')
var s = require('raw!./test.css')

PolymerExt({
  is: 'card-panel',
  template: t,
  style: s,
  ... // other polymer options
})

I just succeeded by means of this loader: 我只是通过这个装载机取得了成功:

https://github.com/aitoroses/vulcanize-loader https://github.com/aitoroses/vulcanize-loader

Unobvious thing is that i had to install the webcomponent that i wanted through bower (yarn does the job too). 不明显的是我必须通过凉亭安装我想要的web组件(纱线也能完成这项工作)。 After that, manually reference it inside manually created importer.html file, and then at the end, reference that importer.html file inside your js module: 之后,在手动创建的importer.html文件中手动引用它,然后在最后,引用js模块中的importer.html文件:

import 'vulcanize!./importer.html';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM