html-script-module-loader
v0.0.1
Published
Webpack loader to transform <script type="module"> to require statements
Downloads
2
Readme
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
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