layout | title | label | permalink | nav_order |
---|---|---|---|---|
page |
Compile Web-Components to JavaScript |
Compiling |
/compile-components/ |
40 |
Compiling Lego component is built-in with no extra installation; pretty straighforward.
LEGO_URL=</url/to/lego.min.js> npx lego <source_path> <target_file_path>
Would compile the source_path file or folder (recursively) into target_file_path js file using lego.min.js from the declared url.
As mentioned before, when developing you probably want to watch for changes with the -w
option: npx lego -w <source_path> <target_file_path>
source_path: either a file or a directory (relative or absolute). If it's a directory, it will recursively read all the .html files and compile them into the target_file.
target_file_path: (default: components.js) the path (relative or absolute) to a .js file. That file will be created and contain all the components.