A monorepo for Ampify's open source plugins and utilities.
Plugin is just an exported function, you have complete control
on the document
as in the browser.
Example:
export default () => {
const el = document.querySelector('.menu');
};
You can also use module.exports:
module.exports = () => {
const el = document.querySelector('.menu');
};
Plugin can return an object with some settings:
classes
- Array of classes to not shorten.
Example:
export default () => {
//...plugin logic here
return {
classes: ['is-open', 'menu', 'header']
};
};
Use yarn build
command to create a bundled plugin in the dist folder.
Plugin is just a function exposed on the window object, you can do it manually, however it is easier to use webpack configuration and build it to use 3rd party dependencies.
Example:
window.myCustomPlugin = () => {
//...plugin logic goes here.
};