0.0.1 • Published 7 years ago

html-script-module-loader v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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