All Projects → aruntk → Wc Loader

aruntk / Wc Loader

Licence: mit
🚽 Webcomponents webpack loader.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Wc Loader

Apollo Elements
🚀🌛 Use the Launch Platform 👩‍🚀👨‍🚀
Stars: ✭ 278 (+175.25%)
Mutual labels:  webcomponents, polymer
Vaadin
An evolving set of open source web components for building mobile and desktop web applications in modern browsers.
Stars: ✭ 424 (+319.8%)
Mutual labels:  webcomponents, polymer
Google Chart
Google Charts API web components
Stars: ✭ 284 (+181.19%)
Mutual labels:  webcomponents, polymer
Highcharts Chart
Polymer Element wrapper for highcharts library. Seamlessly create various types of charts from one element.
Stars: ✭ 97 (-3.96%)
Mutual labels:  webcomponents, polymer
Redux Store Element
A custom element allowing a more declarative use of Redux.
Stars: ✭ 83 (-17.82%)
Mutual labels:  webcomponents, polymer
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (-70.3%)
Mutual labels:  polymer, webcomponents
Awesome Polymer
A collection of awesome Polymer resources.
Stars: ✭ 384 (+280.2%)
Mutual labels:  webcomponents, polymer
vaadin-split-layout
The Web Component which allows you to partition a layout into resizeable areas. Part of the Vaadin components.
Stars: ✭ 40 (-60.4%)
Mutual labels:  polymer, webcomponents
Login Fire
An element that allows simple configuration of multiple provider login for firebase
Stars: ✭ 58 (-42.57%)
Mutual labels:  webcomponents, polymer
Gwt Api Generator
Generator for creating GWT JSInterop clients from Polymer Web Components
Stars: ✭ 49 (-51.49%)
Mutual labels:  webcomponents, polymer
vaadin-icons
Vaadin Icons is a collection of 600+ unique icons designed for web applications
Stars: ✭ 59 (-41.58%)
Mutual labels:  polymer, webcomponents
Vaadin Upload
The Web Component for uploading multiple files with progress indication. Part of the Vaadin components.
Stars: ✭ 87 (-13.86%)
Mutual labels:  webcomponents, polymer
dom-repeat-n
[Polymer 1.x] A template element that repeat n times its content.
Stars: ✭ 20 (-80.2%)
Mutual labels:  polymer, webcomponents
vaadin-text-field
The themable Web Component providing input controls. Part of the Vaadin components.
Stars: ✭ 29 (-71.29%)
Mutual labels:  polymer, webcomponents
vaadin-checkbox
The Web Component for customized checkboxes. Part of the Vaadin components.
Stars: ✭ 18 (-82.18%)
Mutual labels:  polymer, webcomponents
Vaadin Core
An evolving set of free, open source web components for building mobile and desktop web applications in modern browsers.
Stars: ✭ 382 (+278.22%)
Mutual labels:  webcomponents, polymer
multiselect-combo-box
A multi select combo box web component based on Polymer and the vaadin-combo-box
Stars: ✭ 41 (-59.41%)
Mutual labels:  polymer, webcomponents
vaadin-context-menu
The responsive Web Component for showing context dependent items for any element on the page. Part of the Vaadin components.
Stars: ✭ 26 (-74.26%)
Mutual labels:  polymer, webcomponents
Vaadin Form Layout
The Web Component providing configurable responsive layout for form elements. Part of the Vaadin components.
Stars: ✭ 15 (-85.15%)
Mutual labels:  webcomponents, polymer
Lit Loader
LitElement Single File Component loader for Webpack.
Stars: ✭ 84 (-16.83%)
Mutual labels:  webpack, polymer

WC Loader

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

About

wc-loader helps you use webcomponents (polymer, x-tags etc also) with webpack.

Under the hood

wc-loader uses parse5 which parses HTML the way the latest version of your browser does. Does not use any regex to parse html. :)

Main functions
  1. Handles html link imports. With Hot Code Reload Support
  2. Handles external script files (script src). With Hot Code Reload Support
  3. Handles external css files (link rel stylesheet)
  4. Handles template tags.
  5. Removes comments and unecessary whitespaces.
  6. Handles loading order of html and js inside the polymer files
  7. Adds components to document during runtime.

Installation

npm i -D wc-loader

Usage

module: {
    rules: [
      {
        test: /\.js$/, // handles js files. <script src="path.js"></script> and import 'path';
        use: [{
          loader: 'babel-loader',
        }],
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/, // handles assets. eg <img src="path.png">
        use: [{
          loader: 'file-loader',
          options: {
            name: '[name].[ext]?[hash]'
          }
        }]
      },
      {
        test: /\.html$/, // handles html files. <link rel="import" href="path.html"> and import 'path.html';
        use: [
          // if you not using es6 inside html remove babel-loader
          {

            loader: 'babel-loader',
            // similarly you can use coffee, typescript etc.
          },
          {
            loader: 'wc-loader',
            options: {
              minify: true,
            },
          }]
      },
    ],
  ]
}

Using es6, typescript, coffee etc inside html

In the following config

{
  test: /\.html$/,
  use: [
    {
      loader: 'babel-loader', // change this line
    },
    {
      loader: 'wc-loader',
      options: {
        minify: true,
      },
    }]
},

if you are using es6 inside html use

loader: 'babel-loader'

similarly you can use coffee, typescript etc. pipe wc result through the respective loader.

loader: 'ts-loader'
loader: 'coffee-loader'

Options

You can either specify options as part of the loader string or as options property

{
  loader: 'wc-loader',
  options: {
    minify: true
  }
}

'Root-relative' URLs

For urls that start with a /, the default behavior is to not translate them. You'll get a file not found error in the browser. (/path = example.com/path for the browser) If a root query parameter is set, however, it will be prepended to the url and then translated.

<!-- file.html -->
<img src="/image.jpg">
// webpack config. options.root can also be used

loader: 'wc-loader?root=/absolue/path/to/root/folder'

// or

loader: 'wc-loader?root=' + path.resolve('relative/path/to/root/folder')

// example

loader: 'wc-loader?root=/'

Minify html

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

options: {
   minify: true,
   minifierOptions: {
     // custom options
   }
}

Like it?

⭐️ this repo

Found a bug?

Raise an issue!

License

MIT. Check licence file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].