Metal.js HomeMetal.js
  • Documentation
Docs Menu
  • Tutorials
    • Todo App: JSX
    • Todo App: Soy
  • Guides
    • Alias
    • State
    • Component Lifecycle
    • Rendering Components
    • Inline Events
    • Importing a Third Party Component
    • Soy Components
    • JSX Components
    • Portals
    • Progressive Enhancement
    • Yeoman Generator
    • Building
    • Performance
    • Web Components
    • Isomorphic Rendering

Building Guide

As we mentioned before, Metal.js components are written in ES6, which means that we need a transpiling process before using it on a website.

This can be done via any tools that you prefer, like webpack or browserify, but we've also published a few tools of our own, which focuses on Metal.js projects, which we'll talk about here.

metal-tools-soy

This tool is required when building Metal.js components that use Soy. It takes the .soy files in your project and transpiles them to JavaScript that can then be imported in your component js files.

It's suggested to run this tool as a CLI, but it can also be run programmatically if necessary.

Take a look at the project's documentation for more information.

If you are using webpack to bundle your Metal.js components, you can optionally use the metal-soy-loader which conveniently wraps metal-tools-soy for use with webpack.

babel-preset-metal-jsx

When building Metal.js JSX components, it is necessary to transpile the JSX to JavaScript. The babel-preset-metal-jsx package takes care of importing the necessary babel plugins that allow for this transpilation.

Examples

To see examples of these tools in action, check out the Yeoman Generator. The boilerplate it generates for both Soy and JSX components implement these tools out of the box.

Contribute on Github! Edit this section.