Coder Social home page Coder Social logo

lshapz / es6g-init Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rdig/es6g-init

0.0 2.0 0.0 1.68 MB

An init package to get you up and running **fast** with a clean environment to prototype with javascript.

License: MIT License

JavaScript 100.00%

es6g-init's Introduction

Javascript ES6 Gulp Init Package for Prototyping

An init package (you could view it as an boilerplate, but that would be an over-simplification) to get you up and running fast with a clean environment to prototype with javascript.

It's meant to build simple code / figuring out how things work as opposed to building web applications (although it features a web server for all your in-browser needs).

Show

es6g-init quick usage

Tell

Features:

  • ES6 Syntax transpiling w/ stage-0
  • Automatic .js file injection into .html (browser mode)
  • Permissive of minified .js files (eg: external libraries brought in)
  • Local web server w/ auto-reloading
  • File bundling (terminal mode)
  • Watching files for changes
  • Run the files in the terminal (via node.js) w/ auto-reloading

Quick start

Automatically via NPM

Create a new folder and enter it:

mkdir <your-new-project-folder>
cd <your-new-project-folder>

Install the node package (it will trigger all the additional scripts automatically, and set up everything for you):

npm i es6g-init

Or you can run this in one line:

mkdir <your-new-project-folder> && cd <your-new-project-folder> && npm i es6g-init

Manual via this repository

Clone the repository into a new folder (your new project's folder):

git clone [email protected]:rdig/a1w-init.git <your-new-project-folder>

Enter your new folder:

cd <your-new-project-folder>

Just run the npm install script which will set up the project for you

npm install

How to use

Start writing Javascript in a .js file and it will figure out what you want to do and include your files for your.

In any mode you start it terminal or browser, it will look in the source folder for any .js script (including minified .min.js files) and include them.

Minified files always are included first since we assume they are external libraries.

In terminal mode our .js files are traspiled (except the minified ones), all of them bundled into a single one, moved into the build folder, then the bundle is will be run inside the console, with a file watcher that listens for changes.

In browser mode all your .js files are inserted into the index.html file's designated comment block (find out more), the .js files are transpiled, then all of them (.js, .min.js, .html) are moved into the build folder. A web server is spawned for that folder with an auto-reload / file watcher listening for changes.

Run Modes

  • Terminal - Start development in the current terminal window. In will be refreshed anythime it detects a file change on any .js files.

  • Browser - Starts developemnt using a local web server. Open http://localhost:8080 in your browser. It will auto-reload every time it detects a change in a .js or .html file.

NPM commands

To run the tasks use NPM's run command:

npm run <task_name>

These are the available tasks you can use:

  • terminal: Start local development development in terminal mode.
  • term: Same as terminal.
  • browser: Start development in browser mode.
  • http: Same as browser.

There is also a shorter command, npm start which defaults to starting development in terminal mode.

Sample files

The project is delivered by default with an index.html and app.js so you could verify that everything is working as it should. These should run in both terminal and browser modes.

Make note of the comment blocks inside of index.html.

<!-- inject:js -->
<!-- endinject -->

These serve as anchors for gulp-inject to link to your created .js files. If you want to know more about them heve a look at github.com/klei/gulp-inject#optionsstarttag.

Tech stack

Node.js

A javascript runtime built on chrome's engine (like you didn't already know what node is...).

More Info: github.com/nodejs/node

Gulp

Task runner and orchestrator (well, there's npm...) of various services (transpiling, http server, file watcher, ...).

More info: gulpjs.com

There are also a number of other packages (gulp plugins) used for various task:

Del

Clean the environment before transpiling / re-transpiling files.

More info: github.com/sindresorhus/del

Babel

Used to tranpile javascript files. It contains the following presets:

Wait-on

Utility to wait for a resource (file, url) to become available, then execute an action on / for it.

More info: github.com/jeffbski/wait-on

Requirements

  • Node.js - Either node version works 4.x or 6.x, but the 4.x version will spit out an excessive amount of warnings (some packages are only maintained for node 6.x+).
  • Git - Either version is fine for this project, but if you can trick your package manager into installing the latest one, that would be super.

Folder structure

  • source - Source folder where you should put your files
  • build - Destination folder where Gulp will build / transpile / move the processed files.

Both these folders can be easily changed inside the gulpfile's configuration object (configObject).

Contributing

We welcome contributions of every form, shape or size. Just have a gander at CONTRIBUTING.MD to figure out how to get started.

License

See LICENSE

es6g-init's People

Contributors

rdig avatar lshapz avatar

Watchers

James Cloos avatar  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.