All Projects → PatrickJS → Ng6 Starter

PatrickJS / Ng6 Starter

Licence: apache-2.0
🆖 An AngularJS Starter repo for AngularJS + ES6 + Webpack

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Ng6 Starter

Myblog
我的个人博客,记录自己的所学所享.
Stars: ✭ 71 (-96.33%)
Mutual labels:  webpack, gulp
Angular Material Dashboard
Angular admin dashboard with material design
Stars: ✭ 1,321 (-31.66%)
Mutual labels:  gulp, angularjs
Component Pattern For Angular Js 1 X
Example of implementation of Component pattern for Angular JS 1.X using ES6 & Webpack
Stars: ✭ 75 (-96.12%)
Mutual labels:  webpack, angularjs
Jekyll Boilerplate
Helpful files to get started working on a new Jekyll website
Stars: ✭ 30 (-98.45%)
Mutual labels:  webpack, gulp
Csdwheels
一套基于原生JavaScript开发的插件,无依赖、体积小
Stars: ✭ 114 (-94.1%)
Mutual labels:  webpack, gulp
Tested
Angular Material in MEAN Stack Website Source
Stars: ✭ 35 (-98.19%)
Mutual labels:  webpack, angularjs
Npm Pipeline Rails
Use npm as part of your Rails asset pipeline
Stars: ✭ 93 (-95.19%)
Mutual labels:  webpack, gulp
Initior
A command line application that let's you initialize your new projects the right way, replaces npm and yarn's init 🎆
Stars: ✭ 17 (-99.12%)
Mutual labels:  webpack, gulp
Angular To React Redux
Angular to React/Redux, a Guide for Angular v1 Experts Looking to Learn React/Redux
Stars: ✭ 109 (-94.36%)
Mutual labels:  webpack, angularjs
Frontie Webpack
Front-end Boilerplate | Gulp 4 + Webpack 4 + Babel + ITCSS Architecture + BEM Methodology + Twig.js
Stars: ✭ 102 (-94.72%)
Mutual labels:  webpack, gulp
Wordpress Starter
📦 A starter template for WordPress websites
Stars: ✭ 26 (-98.65%)
Mutual labels:  webpack, gulp
Generator Phaser Plus
[🛑 DISCONTINUED] It has been a long journey but development of `generator-phaser-plus` is now over. I recommend you have a look and fork `yandeu/phaser-project-template` instead.
Stars: ✭ 148 (-92.34%)
Mutual labels:  webpack, gulp
Puppy
Starter kit and delivery system for building static prototypes with Twig
Stars: ✭ 25 (-98.71%)
Mutual labels:  webpack, gulp
Generator Kittn
The Yeoman Kittn Generator
Stars: ✭ 63 (-96.74%)
Mutual labels:  webpack, gulp
Manhuaren
vue2.0全家桶,仿漫画人官网(移动端)
Stars: ✭ 18 (-99.07%)
Mutual labels:  webpack, gulp
Angular2 Demo
A simple demo for Angular 2
Stars: ✭ 77 (-96.02%)
Mutual labels:  webpack, angularjs
Generator Ng Fullstack
Client, server or fullstack - it's up to you. ng-fullstack gives you the best of the latest.
Stars: ✭ 701 (-63.74%)
Mutual labels:  webpack, gulp
Nice Front End Tutorial
🌍 Constantly updated front-end resources, tutorials, opinions(与时俱进版前端资源,教程和意见。)
Stars: ✭ 755 (-60.94%)
Mutual labels:  webpack, gulp
Ng Boot Oauth
oauth2 demo with angularjs and springboot
Stars: ✭ 99 (-94.88%)
Mutual labels:  webpack, angularjs
Vue Webgulp
Vue.js + Webpack + Gulp + Vue Loader
Stars: ✭ 146 (-92.45%)
Mutual labels:  webpack, gulp

ng6-starter

NG6 Join Slack Join the chat at https://gitter.im/angularclass/NG6-starter

The de facto starter repo for building scalable apps with Angular, ES6, and Webpack

This repo serves as a minimal starter for those looking to get up-and-running with Angular and ES6, using Gulp and Webpack for the build process. This seed is not a Yeoman generator. It's a minimal starter with tasks for building the boilerplate. These are its features:

  • The best practice in directory/file organization for Angular (allowing for infinite horizontal app scaling)
  • A ready-to-go build system for working with ES6
  • Tasks for generating additional boilerplate Angular components
  • A full testing system in place
  • SASS support via node-sass

Check out the JSPM version--an alternative to Webpack as an ES6 build system.

If you're looking for a preliminary Angular 2 build, please use the angular2-webpack-starter.


Table of Contents

Walkthrough

Build System

NG6 uses NPM scripts, Gulp, and Webpack together for its build system. Yes, you don't need Gulp if you're using Webpack. This is true if your build system is only responsible for file manipulation. However, ours is not.

Webpack handles all file-related concerns:

  • Transpiling from ES6 to ES5 with Babel
  • Loading HTML files as modules
  • Transpiling stylesheets and appending them to the DOM
  • Refreshing the browser and rebuilding on file changes
  • Hot module replacement for transpiled stylesheets
  • Bundling the app
  • Loading all modules
  • Doing all of the above for *.spec.js files as well

Gulp is the orchestrator:

  • Starting and calling Webpack
  • Starting a development server (yes, Webpack can do this too)
  • Generating boilerplate for the Angular app

Check out the JSPM version--an alternative to Webpack as an ES6 build system.

File Structure

We use a componentized approach with NG6. This will be the eventual standard (and particularly helpful, if using Angular's new router) as well as a great way to ensure a tasteful transition to Angular 2, when the time is ripe. Everything--or mostly everything, as we'll explore (below)--is a component. A component is a self-contained concern--may it be a feature or strictly-defined, ever-present element of the UI (such as a header, sidebar, or footer). Also characteristic of a component is that it harnesses its own stylesheets, templates, controllers, routes, services, and specs. This encapsulation allows us the comfort of isolation and structural locality. Here's how it looks:

client
⋅⋅app/
⋅⋅⋅⋅app.js * app entry file
⋅⋅⋅⋅app.html * app template
⋅⋅⋅⋅common/ * functionality pertinent to several components propagate into this directory
⋅⋅⋅⋅components/ * where components live
⋅⋅⋅⋅⋅⋅components.js * components entry file
⋅⋅⋅⋅⋅⋅home/ * home component
⋅⋅⋅⋅⋅⋅⋅⋅home.js * home entry file (routes, configurations, and declarations occur here)
⋅⋅⋅⋅⋅⋅⋅⋅home.component.js * home "directive"
⋅⋅⋅⋅⋅⋅⋅⋅home.controller.js * home controller
⋅⋅⋅⋅⋅⋅⋅⋅home.scss * home styles
⋅⋅⋅⋅⋅⋅⋅⋅home.html * home template
⋅⋅⋅⋅⋅⋅⋅⋅home.spec.js * home specs (for entry, component, and controller)

Testing Setup

All tests are also written in ES6. We use Webpack to take care of the logistics of getting those files to run in the various browsers, just like with our client files. This is our testing stack:

  • Karma
  • Webpack + Babel
  • Mocha
  • Chai

To run tests, type npm test in the terminal. Read more about testing below.

Getting Started

Dependencies

Tools needed to run this app:

  • node and npm

Installing

  • fork this repo
  • clone your fork
  • npm install to install dependencies

Running the App

NG6 uses Gulp to build and launch the development environment. After you have installed all dependencies, you may run the app. Running npm start will bundle the app with webpack, launch a development server, and watch all files. The port will be displayed in the terminal.

Tasks

Here's a list of available tasks:

  • npm run build
    • runs Webpack, which will transpile, concatenate, and compress (collectively, "bundle") all assets and modules into dist/bundle.js. It also prepares index.html to be used as application entry point, links assets and created dist version of our application.
  • npm run serve
    • starts a dev server via webpack-dev-server, serving the client folder.
  • npm run watch
    • alias of serve
  • npm start (which is the default task that runs when typing gulp without providing an argument)
    • runs serve.
  • npm run component
    • scaffolds a new Angular component. Read below for usage details.

Testing

To run the tests, run npm test.

Karma combined with Webpack runs all files matching *.spec.js inside the app folder. This allows us to keep test files local to the component--which keeps us in good faith with continuing to build our app modularly. The file spec.bundle.js is the bundle file for all our spec files that Karma will run.

Be sure to define your *.spec.js files within their corresponding component directory. You must name the spec file like so, [name].spec.js. If you don't want to use the .spec.js suffix, you must change the regex in spec.bundle.js to look for whatever file(s) you want. Mocha is the testing suite and Chai is the assertion library. If you would like to change this, see karma.conf.js.

Examples

It's always easier to learn something if you have an examples. Here is a list of repos which based on this starter:

Generating Components

Following a consistent directory structure between components offers us the certainty of predictability. We can take advantage of this certainty by creating a gulp task to automate the "instantiation" of our components. The component boilerplate task generates this:

⋅⋅⋅⋅⋅⋅componentName/
⋅⋅⋅⋅⋅⋅⋅⋅componentName.js // entry file where all its dependencies load
⋅⋅⋅⋅⋅⋅⋅⋅componentName.component.js
⋅⋅⋅⋅⋅⋅⋅⋅componentName.controller.js
⋅⋅⋅⋅⋅⋅⋅⋅componentName.html
⋅⋅⋅⋅⋅⋅⋅⋅componentName.scss // scoped to affect only its own template
⋅⋅⋅⋅⋅⋅⋅⋅componentName.spec.js // contains passing demonstration tests

You may, of course, create these files manually, every time a new module is needed, but that gets quickly tedious. To generate a component, run npm run component -- --name componentName.

The parameter following the --name flag is the name of the component to be created. Ensure that it is unique or it will overwrite the preexisting identically-named component.

The component will be created, by default, inside client/app/components. To change this, apply the --parent flag, followed by a path relative to client/app/components/.

For example, running npm run component -- --name signup --parent auth will create a signup component at client/app/components/auth/signup.

Running npm run component -- --name footer --parent ../common creates a footer component at client/app/common/footer.

Because the argument to --name applies to the folder name and the actual component name, make sure to camelcase the component names.

Starter Kit Support and Questions

Contact us, anytime, regarding anything about this project.


enjoy — PatrickJS

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].