TheScienceMuseum / web-design-system

Documentation and component library for elements of SMG websites
https://thesciencemuseum.github.io/web-design-system/
Other
0 stars 0 forks source link

How to consume the javascript? #2

Closed tobystokes closed 5 years ago

tobystokes commented 5 years ago

Use cases:

ES2015 module import:

General use in bundled web project (e.g. Blogs)

import * as smg from 'smg-design-system';
smg.accordions()

CommonJS module require:

Alt use in node.js (e.g. Collections)

const smg = require('smg-design-system');
smg.accordions()

For simple/quick uses, without build process, use the library by loading it via a script tag:

<html>
  <script src="https://cdn/smg/module.min.js"></script>
  <script>
    smg.accordions();
  </script>
</html>

This (probably?) requires outputting a few different formats (bundle.js / bundle.es6.js ) into the dist folder used by npm.

Can't find an easy way to do this via browserify - switch to webpack?