简体   繁体   中英

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. 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.

Unfortunately, Polymer 1.0 is presently unsupported by polymer-loader due to an API change. 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

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

Unobvious thing is that i had to install the webcomponent that i wanted through bower (yarn does the job too). 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:

import 'vulcanize!./importer.html';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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