1.0.0 • Published 3 years ago

html-node-loader v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

HTML Node Loader is a loader for webpack that will load a given HTML file as DOM.

Installation

Using npm:

$ npm install html-node-loader --save-dev

Usage

In webpack.config.js:

module: {
    rules: [
        {
            test: /\.html$/i,
            use: [ {
                loader: 'html-node-loader',
                options: {
                    wrap: false
                }
            } ],
        },
    ]
}

In yor JS files you can now simply import the HTML file:

// index.js
import example from "example.html"

consol.log(example.innerText);
<!-- example.html -->
<p>Hello!</p>

Options

wrap: Will wrap the parsed html in a <span> (default: true)

NOTE: Setting wrap to false will return the firstChild of the span