![](https://raw.githubusercontent.com/webcomponents/webcomponents-icons/master/logo/logo_512x512.png)
Webcomponents webpack loader . Supports hot code reload. ๐ฝ ๐
DEMO - https://github.com/aruntk/polymer-webpack-demo
Polymer Webpack Apollo-Graphql Demo - https://github.com/aruntk/githunt-polymer
wc-loader helps you use webcomponents (polymer, x-tags etc also) with webpack.
wc-loader uses parse5 which parses HTML the way the latest version of your browser does. Does not use any regex to parse html. :)
- Handles html link imports. With Hot Code Reload Support
- Handles external script files (script src). With Hot Code Reload Support
- Handles external css files (link rel stylesheet)
- Handles template tags.
- Removes comments and unecessary whitespaces.
- Handles loading order of html and js inside the polymer files
- Adds components to document during runtime.
npm i -D wc-loader
module: {
loaders: [
{
test: /\.html$/, // handles html files. <link rel="import" href="path.html"> and import 'path.html';
loader: 'wc-loader'
// if you are using es6 inside html use
// loader: 'babel-loader!wc-loader'
// similarly you can use coffee, typescript etc. pipe wc result through the respective loader.
},
{
test: /\.js$/, // handles js files. <script src="path.js"></script> and import 'path';
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/, // handles assets. eg <img src="path.png">
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
},
]
}
if you are using es6 inside html use
loader: 'babel-loader!wc-loader'
similarly you can use coffee, typescript etc. pipe wc result through the respective loader.
loader: 'ts-loader!wc-loader'
loader: 'coffee-loader!wc-loader'
loader: 'babel-loader!wc-loader?minify=true'
default options are
const defaultMinifierOptions = {
collapseWhitespace: true,
customAttrAssign: [/\$=/],
ignoreCustomFragments: [/style\$?="\[\[.*?\]\]"/],
}
Use custom options - by config setting minifierOptions
Refer https://github.com/kangax/html-minifier for more info
โญ this repo
Raise an issue!
MIT. Check licence file.