GithubHelp home page GithubHelp logo

steal's Introduction

StealJS

Build Status

StealJS is an ES6, AMD, CommonJS, and steal client-side loader. Combined with steal-tools, its designed to simplify dependency management while being extremely powerful and flexible.

Steal builds from SystemJS and ES6ModuleLoader and adds:

  • global configuration
  • css and less support
  • plugin extension mapping (upcoming)
  • production builds with steal-tools

But it's killer feature - progressively loaded apps that balance caching and the number of script requests.

StealJS supports IE8+ with AMD, CommonJS, and Steal syntax and IE9+ for ES6 syntax.

Use

Hello World Example

Lets see how to get a basic app up and running.

  1. Install StealJS:

With Bower

bower install steal#0.1.1 -S

  1. Create stealconfig.js:

Add a stealconfig.js file directly within your "root" folder. Your "root" folder should contain all your static scripts and resources.

By default, steal will assume stealconfig.js is a sibling of bower_components:

  ROOT/
    bower.json
    bower_components
    stealconfig.js

stealconfig.js will be loaded by every page in your project. It is used to configure the location to modules and other behavior.

  1. Add main module:

Add a main.js to your project. This will load your apps other modules.

  ROOT/
    bower.json
    bower_components
    stealconfig.js
    main.js

Within main.js add:

console.log("hello world");
  1. Create an HTML page:

Create an index.html page that specifies the location of stealconfig.js and the main module name:

  ROOT/
    bower.json
    bower_components
    stealconfig.js
    index.html

Within index.html add:

<!DOCTYPE html>
<html>
  <body>
    <script src='./bower_components/steal/steal.js'
            data-config='stealconfig.js'
            data-main='main'></script>
  </body>
</html>

To build this app, read StealTools docs.

Adding jQuery

  1. Install jQuery:

    With Bower

    bower install jquery -S

  2. Configure jQuery's path and export:

    Add a config for System.paths to stealconfig.js to tell steal where to find jQuery. Add a config for System.meta to tell SystemJS that jQuery exports the "jQuery" variable.

    System.paths.jquery = "bower_components/jquery/dist/jquery.js";
    System.meta.jquery = { exports: "jQuery" };
  3. Load jQuery.

Import "jquery" with ES6 module syntax in main.js:

import $ from "jquery";
$(document.body).append("<h1>Hello World!</h1>");

Developing

After cloning ...

  1. Install npm modules

    npm install

  2. Install bower modules

    bower install

  3. Setup grunt watch

    grunt watch

This will automatically build when anything in src change.

To test, open:

  test/test.html

And make sure everything passes.

steal's People

Contributors

daffl avatar justinbmeyer avatar matthewp avatar retro avatar

Watchers

James Cloos avatar Andrew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.