Skip to content

Commit 6f3c677

Browse files
committed
init commit
0 parents  commit 6f3c677

26 files changed

+756
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules/
3+
bower_components/
4+
dist/

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# WMi Angular Kit
2+
3+
Production Ready Boilerplate Framework For Angular
4+
5+
### Node Modules
6+
7+
- Gulp + Plugins
8+
- Babel
9+
- BrowserSync
10+
- RunSequence
11+
12+
### Bower Components
13+
14+
- Angular
15+
- Angular Route
16+
- Angular Animate
17+
- Angular Sanitize
18+
- Angular UI Bootstrap
19+
- Moment
20+
- Lodash
21+
22+
# Installation
23+
_____
24+
25+
**Contributing to this project:**
26+
27+
`npm install && bower install` - install dependencies
28+
29+
**Starting a new project:**
30+
31+
`npm run kit` - install dependencies & remove git
32+
33+
**One step copy & paste install:**
34+
35+
This will clone the repo, rename the project to "myWebApp" and install everything you'll need.
36+
37+
`git clone https://github.com/worldmedia/wmi-angular-kit.git && mv wmi-angular-kit/ myWebApp && cd myWebApp && npm run kit`
38+
39+
# Usage
40+
_____
41+
42+
Update the following naming conventions:
43+
44+
**src/app.js**: `const _MODULE = 'your-app-name';`
45+
46+
**gulpfile.js**: Change `app.module` to `'your-app-name'`
47+
48+
**/src/index.html**: `ng-app="your-app-name"`
49+
50+
# Serve
51+
_____
52+
53+
`gulp serve`

bower.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "wmi-angular-kit",
3+
"version": "1.0.0",
4+
"homepage": "https://github.com/worldmedia/wmi-angular-kit",
5+
"authors": [
6+
"WMI"
7+
],
8+
"description": "WMI Angular Kit",
9+
"main": "gulpfile.js",
10+
"license": "MIT",
11+
"private": true,
12+
"ignore": [
13+
"**/.*",
14+
"node_modules",
15+
"bower_components"
16+
],
17+
"dependencies": {
18+
"angular-sanitize": "~1.5.0",
19+
"angular": "~1.5.0",
20+
"angular-route": "~1.5.0",
21+
"angular-animate": "^1.5.0",
22+
"angular-bootstrap": "^1.2.4",
23+
"bootstrap": "^3.3.6",
24+
"moment": "^2.12.0",
25+
"lodash": "^4.6.1"
26+
}
27+
}

gulpfile.js

+244
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
var gulp = require('gulp');
2+
var babel = require('gulp-babel');
3+
var clean = require('gulp-clean');
4+
var concat = require('gulp-concat');
5+
var sass = require('gulp-sass');
6+
var uglify = require('gulp-uglify');
7+
var inject = require('gulp-inject');
8+
var htmlmin = require('gulp-htmlmin');
9+
var runSequence = require('run-sequence');
10+
var browserSync = require('browser-sync').create();
11+
var templateCache = require('gulp-angular-templatecache');
12+
13+
var app = {
14+
module : 'wmi',
15+
dist : './dist',
16+
index : './src/index.html',
17+
icons : './src/*.{ico,png}',
18+
json : './src/json/**/*.json',
19+
html : [
20+
'./src/html/**/*.html',
21+
'./src/components/**/*.html'
22+
],
23+
fonts : [
24+
'./src/fonts/**/*.{eot,svg,ttf,woff,woff2}',
25+
'./src/components/**/*.{eot,svg,ttf,woff,woff2}'
26+
],
27+
// mandatory array order, see app:css task
28+
css : [
29+
'./src/scss/styles.scss',
30+
'./src/components/**/*.scss',
31+
'./src/scss/**/*.scss'
32+
],
33+
img : [
34+
'./src/img/**/*.{gif,jpg,jpeg,png,svg}',
35+
'./src/components/**/*.{gif,jpg,jpeg,png,svg}'
36+
],
37+
js : [
38+
'./src/app.js',
39+
'./src/js/**/*.js',
40+
'./src/components/**/*.js'
41+
]
42+
};
43+
44+
var vendor = {
45+
fonts: [
46+
'./bower_components/bootstrap/dist/fonts/*.{eot,svg,ttf,woff,woff2}'
47+
],
48+
css: [
49+
'./bower_components/bootstrap/dist/css/bootstrap.min.css'
50+
],
51+
js: [
52+
'./bower_components/angular/angular.min.js',
53+
'./bower_components/angular-route/angular-route.min.js',
54+
'./bower_components/angular-animate/angular-animate.min.js',
55+
'./bower_components/angular-sanitize/angular-sanitize.min.js',
56+
'./bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
57+
'./bower_components/moment/min/moment.min.js',
58+
'./bower_components/lodash/dist/lodash.min.js'
59+
]
60+
};
61+
62+
// UTILITIES
63+
gulp.task('clean', function() {
64+
return gulp.src(app.dist, {read:false})
65+
.pipe(clean());
66+
});
67+
68+
gulp.task('browserSync', function() {
69+
return browserSync.init({
70+
server: {
71+
baseDir: app.dist
72+
}
73+
});
74+
});
75+
76+
gulp.task('reload', function() {
77+
return browserSync.reload();
78+
});
79+
80+
// VENDOR FONTS TASKS
81+
gulp.task('vendor:fonts', function() {
82+
return gulp.src(vendor.fonts)
83+
.pipe(gulp.dest(app.dist + '/fonts'));
84+
});
85+
86+
// VENDOR CSS TASKS
87+
gulp.task('vendor:css', function() {
88+
return gulp.src(vendor.css)
89+
.pipe(concat('vendor.min.css'))
90+
.pipe(sass({outputStyle:'compressed'}).on('error', sass.logError))
91+
.pipe(gulp.dest(app.dist + '/css'));
92+
});
93+
94+
// VENDOR JS TASKS
95+
gulp.task('vendor:js', function() {
96+
return gulp.src(vendor.js)
97+
.pipe(concat('vendor.min.js'))
98+
.pipe(uglify())
99+
.pipe(gulp.dest(app.dist + '/js'));
100+
});
101+
102+
// APP FONTS TASKS
103+
gulp.task('app:fonts', function() {
104+
return gulp.src(app.fonts)
105+
.pipe(gulp.dest(app.dist + '/fonts'));
106+
});
107+
108+
// APP ICONS TASKS
109+
gulp.task('app:icons', function() {
110+
return gulp.src(app.icons)
111+
.pipe(gulp.dest(app.dist));
112+
});
113+
114+
// APP JSON TASKS
115+
gulp.task('app:json', function() {
116+
return gulp.src(app.json)
117+
.pipe(gulp.dest(app.dist + '/json'));
118+
});
119+
120+
// APP CSS TASKS
121+
gulp.task('app:css', function() {
122+
123+
// use styles.scss to determine order
124+
var sortedStream = [
125+
app.css[0],
126+
app.css[1]
127+
];
128+
129+
return gulp.src(sortedStream)
130+
.pipe(concat('app.min.css'))
131+
.pipe(sass({outputStyle:'compressed'}).on('error', sass.logError))
132+
.pipe(gulp.dest(app.dist + '/css'));
133+
});
134+
135+
// APP JS TASKS
136+
gulp.task('app:js', function() {
137+
return gulp.src(app.js)
138+
.pipe(babel())
139+
.pipe(concat('app.min.js'))
140+
.pipe(uglify())
141+
.pipe(gulp.dest(app.dist + '/js'));
142+
});
143+
144+
// APP IMAGE TASKS
145+
gulp.task('app:img', function() {
146+
return gulp.src(app.img)
147+
.pipe(gulp.dest(app.dist + '/img'));
148+
});
149+
150+
// APP HTML TASKS
151+
gulp.task('app:html', function() {
152+
return gulp.src(app.html)
153+
.pipe(htmlmin({collapseWhitespace:true}))
154+
.pipe(templateCache('templates.min.js', {module:app.module}))
155+
.pipe(uglify())
156+
.pipe(gulp.dest(app.dist + '/js'));
157+
});
158+
159+
// APP GLOBAL CSS
160+
gulp.task('app:global:css', function() {
161+
var sortedStream = [
162+
app.dist + '/**/vendor*.css',
163+
app.dist + '/**/app*.css'
164+
];
165+
166+
return gulp.src(sortedStream)
167+
.pipe(concat(app.module + '.min.css'))
168+
.pipe(gulp.dest(app.dist + '/css'));
169+
});
170+
171+
// APP GLOBAL JS
172+
gulp.task('app:global:js', function() {
173+
var sortedStream = [
174+
app.dist + '/**/vendor*.js',
175+
app.dist + '/**/app*.js',
176+
app.dist + '/**/templates*.js'
177+
];
178+
179+
return gulp.src(sortedStream)
180+
.pipe(concat(app.module + '.min.js'))
181+
.pipe(gulp.dest(app.dist + '/js'));
182+
});
183+
184+
// APP INDEX INJECTION
185+
gulp.task('app:index', function() {
186+
var stream = app.dist + '/**/' + app.module + '*.{css,js}';
187+
var filesInject = gulp.src(stream, {read:false});
188+
var injectOptions = {
189+
ignorePath : '/dist/',
190+
addRootSlash : false
191+
};
192+
193+
return gulp.src(app.index)
194+
.pipe(inject(filesInject, injectOptions))
195+
.pipe(htmlmin({collapseWhitespace:true}))
196+
.pipe(gulp.dest(app.dist));
197+
});
198+
199+
// APP WATCH TASKS
200+
gulp.task('watch', function() {
201+
gulp.watch(app.fonts).on('change', function(event) {
202+
console.log(event.path + ' was ' + event.type);
203+
runSequence('app:fonts','reload');
204+
});
205+
gulp.watch(app.icons).on('change', function(event) {
206+
console.log(event.path + ' was ' + event.type);
207+
runSequence('app:icons','reload');
208+
});
209+
gulp.watch(app.json).on('change', function(event) {
210+
console.log(event.path + ' was ' + event.type);
211+
runSequence('app:json','reload');
212+
});
213+
gulp.watch(app.css).on('change', function(event) {
214+
console.log(event.path + ' was ' + event.type);
215+
runSequence('app:css','app:global:css','reload');
216+
});
217+
gulp.watch(app.js).on('change', function(event) {
218+
console.log(event.path + ' was ' + event.type);
219+
runSequence('app:js','app:global:js','reload');
220+
});
221+
gulp.watch(app.img).on('change', function(event) {
222+
console.log(event.path + ' was ' + event.type);
223+
runSequence('app:img','reload');
224+
});
225+
gulp.watch(app.html).on('change', function(event) {
226+
console.log(event.path + ' was ' + event.type);
227+
runSequence('app:html','app:global:js','reload');
228+
});
229+
gulp.watch(app.index).on('change', function(event) {
230+
console.log(event.path + ' was ' + event.type);
231+
runSequence('app:index','reload');
232+
});
233+
});
234+
235+
// BUILD TASKS
236+
gulp.task('build', function(cb) {
237+
runSequence('clean',['vendor:fonts','vendor:css','vendor:js'],['app:fonts','app:icons','app:json','app:css','app:js','app:img','app:html'],['app:global:css','app:global:js'],'app:index',cb);
238+
});
239+
240+
gulp.task('serve', function(cb) {
241+
runSequence('build','browserSync','watch',cb);
242+
});
243+
244+
gulp.task('default',['build']);

package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "wmi-angular-kit",
3+
"version": "1.0.0",
4+
"description": "WMI Angular Kit",
5+
"main": "gulpfile.js",
6+
"scripts": {
7+
"kit" : "npm install && bower install && rm -rf .git"
8+
},
9+
"author": "WMI",
10+
"license": "MIT",
11+
"dependencies": {},
12+
"devDependencies": {
13+
"babel-preset-es2015": "^6.6.0",
14+
"bower": "^1.7.7",
15+
"browser-sync": "^2.11.1",
16+
"gulp": "^3.9.1",
17+
"gulp-angular-templatecache": "^1.8.0",
18+
"gulp-babel": "^6.1.2",
19+
"gulp-clean": "^0.3.1",
20+
"gulp-concat": "^2.6.0",
21+
"gulp-htmlmin": "^1.3.0",
22+
"gulp-inject": "^3.0.0",
23+
"gulp-sass": "^2.2.0",
24+
"gulp-uglify": "^1.5.3",
25+
"run-sequence": "^1.1.5"
26+
}
27+
}

0 commit comments

Comments
 (0)