bookmarklet-loader
v1.0.0
Published
Bookmarklet loader for webpack
Downloads
3
Maintainers
Readme
Bookmarklet loader for webpack
bookmarklet-loader is a webpack loader that will convert any javascript file into a bookmarklet that can be used as a module throughout your application.
Install
npm install bookmarklet-loader webpack --save-dev
The bookmarklet-loader requires webpack
as peerDependency
.
Usage
Apply via webpack config
module.exports = {
...
module: {
loaders: [
{
test: /\.js$/,
loaders: ['bookmarklet-loader'],
include: path.join(__dirname, 'app/bookmarklets')
}
]
}
};
Import into your application
import bookmarklet from 'app/bookmarklets/bookmarklet';
// via JSX
return (
<a href={bookmarklet}>
Click me, I am a bookmarklet.
</a>
);
// via vanilla JS
let link = document.createElement('a');
link.href = bookmarklet;
link.innerHTML = 'Click me, I am a bookmaklet';
return link;