html-script-module-loader

0.0.1 • Public • Published

html-script-module-loader

Webpack loader to transform <script type="module"> to require statements.

Install

npm install html-script-module-loader

You'll also need another loader (like raw-loader or html-loader) to actually load the HTML files.

Usage

Documentation: Using loaders

template.html

<script type="module" src="./nested.js"></script>
<h1>This is the template</h1>

nested.js

console.log('loaded nested.js');

example.js

// Loader order is important. html-script-module-loader operates on JavaScript,
// so it must run *after* (further *left* in the loader string) raw-loader or html-loader.
var template = require('html-script-module-loader!raw-loader!./template.html');
// => "loaded nested.js"
console.log(template);
// => "<h1>This is the template</h1>"

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i html-script-module-loader

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • cletusw