Skip to content

Commit 4c41718

Browse files
do project setup
1 parent 87e9d1f commit 4c41718

File tree

7 files changed

+412
-0
lines changed

7 files changed

+412
-0
lines changed

app/assets/js/app.js

Whitespace-only changes.

app/assets/sass/style.sass

Whitespace-only changes.

app/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Usemin test</title>
5+
<!-- build:css assets/css/style.min.css -->
6+
<link rel="stylesheet" type="text/css" href="./assets/css/styles.css" media="screen" />
7+
<!-- endbuild -->
8+
</head>
9+
<body>
10+
11+
</body>
12+
<!-- build:js assets/js/optimized.js -->
13+
<script src="./assets/js/app.js"></script>
14+
<!-- endbuild -->
15+
</html>

app/views/home.html

Whitespace-only changes.

bower.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "angular-grunt",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"angular": "1.6.1",
6+
"angular-aria": "1.6.1",
7+
"angular-animate": "1.6.1",
8+
"angular-messages": "1.6.1",
9+
"angular-material": "1.1.3",
10+
"angular-chart.js": "~0.8.4",
11+
"angular-cookies": "~1.4.7",
12+
"angular-drag-and-drop-lists": "~1.3.0",
13+
"angular-facebook": "~0.2.3",
14+
"angular-google-plus": "~0.1.3",
15+
"angular-growl-v2": "~0.7.9",
16+
"angular-material-icons": "~0.6.0",
17+
"angular-route": "~1.4.4",
18+
"angular-slimscroll": "~1.1.5",
19+
"angular-timer": "~1.3.3",
20+
"angular-ui-router": "~0.3"
21+
},
22+
"resolutions": {
23+
"angular": "1.6.1"
24+
}
25+
}

gruntfile.js

+333
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,333 @@
1+
'use strict';
2+
3+
module.exports = function(grunt) {
4+
var serverStatic = require('serve-static'); //server-static ==> to run a static server
5+
6+
// require('time-grunt')(grunt); // Time how long tasks take. Can help when optimizing build times
7+
8+
var modRewrite = require('connect-modrewrite'); // live reload ( require for connect-modewrite)
9+
10+
// Loading tasks
11+
require('jit-grunt')(grunt, {
12+
useminPrepare: 'grunt-usemin',
13+
removelogging: 'grunt-remove-logging',
14+
filehash: 'grunt-file-hash'
15+
});
16+
17+
var LocalConfig = {
18+
app: require('./bower.json').appPath || 'app',
19+
20+
// Setting develop & production paths
21+
dev: "app",
22+
dist: "public",
23+
24+
// Setting paths
25+
js: "assets/js",
26+
sass: "assets/sass",
27+
css: "assets/css",
28+
img: "assets/images",
29+
fonts: "assets/fonts"
30+
};
31+
var APP = {
32+
33+
pkg: grunt.file.readJSON("package.json"),
34+
config: LocalConfig,
35+
// Banner
36+
meta: {
37+
banner:
38+
'/*\n' +
39+
' * -------------------------------------------------------\n' +
40+
' * <%= pkg.title %>\n' +
41+
' * Version: <%= pkg.version %>\n' +
42+
' * Site: <%= pkg.author.url %>\n' +
43+
' * Contact: <%= pkg.author.email %>\n' +
44+
' *\n' +
45+
' *\n' +
46+
' * Modify: ' + '<%= grunt.template.today("yyyy-mm-dd h:MM:ss") %>\n' +
47+
' * Copyright (c) <%= grunt.template.today(\'yyyy\') %> \n' +
48+
' * -------------------------------------------------------\n' +
49+
' */\n',
50+
},
51+
// Clean task
52+
// Delete files from dist or .tmp folder
53+
clean: {
54+
dist: {
55+
src: ["<%= config.dist %>"]
56+
},
57+
tmp: {
58+
src: ["<%= config.dev %>/.tmp", ".sass-cache", "<%= config.dev %>/<%= config.css %>"]
59+
}
60+
},
61+
// Copy files to prod path
62+
copy: {
63+
dist: {
64+
files: [
65+
{
66+
expand: true,
67+
dot: true,
68+
cwd: '<%= config.dev %>/',
69+
dest: '<%= config.dist %>/',
70+
src: [
71+
'**',
72+
'*.{md,txt,htaccess}',
73+
'!<%= config.img %>**/.{png,jpg,jpeg,gif}',
74+
'!_**/**',
75+
'!**.{html,php}',
76+
'!<%= config.css %>/**',
77+
'!assets/build-font/**',
78+
'!<%= config.sass %>/**',
79+
'!<%= config.js %>/**/**',
80+
'!.tmp/**',
81+
'!<%= config.js %>/*.js'
82+
],
83+
}
84+
]
85+
}
86+
},
87+
// Compiles Sass to CSS and generates necessary files if requested
88+
compass: {
89+
options: {
90+
sassDir: '<%= config.dev %>/<%= config.sass %>',
91+
cssDir: '<%= config.dev %>/<%= config.css %>',
92+
generatedImagesDir: '.tmp/images/generated',
93+
javascriptsDir: '<%= config.dev %>/<%= config.js %>',
94+
imagesDir: '<%= config.dev %>/<%= config.img %>',
95+
fontsDir: '<%= config.dev %>/<%= config.fonts %>',
96+
importPath: './bower_components',
97+
httpGeneratedImagesPath: '/images/generated',
98+
relativeAssets: false,
99+
assetCacheBuster: false,
100+
raw: 'Sass::Script::Number.precision = 10\n'
101+
},
102+
dev: {
103+
options: {
104+
httpImagesPath: '../../images',
105+
httpFontsPath: '../fonts'
106+
}
107+
},
108+
dist: {
109+
options: {
110+
httpImagesPath: '../../assets/images',
111+
httpFontsPath: '../../assets/fonts'
112+
}
113+
},
114+
server: {
115+
options: {
116+
sourcemap: true
117+
}
118+
}
119+
},
120+
121+
//minify HTML
122+
htmlmin: {
123+
dist: {
124+
options: {
125+
removeComments: true,
126+
collapseWhitespace: false
127+
},
128+
files: [
129+
{
130+
expand: false,
131+
cwd: '<%= config.dev %>/',
132+
src: '*.{html,php}',
133+
dest: '<%= config.dist %>/',
134+
}
135+
],
136+
}
137+
},
138+
// imagemin
139+
imagemin: {
140+
dist: {
141+
files: [{
142+
expand: false,
143+
cwd: '<%= config.dev %>/<%= config.img %>',
144+
src: '{,*/}*.{png,jpg,jpeg,gif}',
145+
dest: '<%= config.dist %>/<%= config.img %>'
146+
}],
147+
}
148+
},
149+
// Make sure code styles are up to par and there are no obvious mistakes
150+
jshint: {
151+
options: {
152+
jshintrc: '.jshintrc',
153+
reporter: require('jshint-stylish')
154+
},
155+
all: {
156+
src: [
157+
'Gruntfile.js',
158+
'<%= config.dev %>/<%= config.js %>/{,*/}*.js'
159+
]
160+
}
161+
},
162+
163+
// Reads HTML for usemin blocks to enable smart builds that automatically
164+
// concat, minify and revision files. Creates configurations in memory so
165+
// additional tasks can operate on them
166+
useminPrepare: {
167+
html: '<%= config.dev %>/index.html',
168+
options: {
169+
dest: '<%= config.dist %>',
170+
flow: {
171+
html: {
172+
steps: {
173+
js: ['concat', 'uglifyjs'],
174+
css: ['cssmin']
175+
},
176+
post: {}
177+
}
178+
}
179+
}
180+
},
181+
182+
// usemin
183+
usemin: {
184+
options: {
185+
config: ['<%= config.dist %>']
186+
},
187+
html: ['<%= config.dist %>/{,*/}*.html']
188+
},
189+
190+
// ng-annotate tries to make the code safe for minification automatically
191+
// by using the Angular long form for dependency injection.
192+
ngAnnotate: {
193+
dist: {
194+
files: [{
195+
expand: true,
196+
cwd: '.tmp/concat/assets/js',
197+
src: '*.js',
198+
dest: '.tmp/concat/assets/js'
199+
}]
200+
}
201+
},
202+
// watch
203+
watch : {
204+
options: { livereload: true },
205+
css: {
206+
files: ["<%= config.dev %>/<%= config.sass %>/**/*.{scss,sass}"],
207+
tasks: ["compass:dev"]
208+
},
209+
js: {
210+
files: ["gruntfile.js", "<%= config.dev %>/<%= config.js %>/**/{,*/}*.js"],
211+
//tasks: ["jshint.all"]
212+
},
213+
html: {
214+
files: [
215+
"/*.{html,htm,shtml,shtm,xhtml,php,jsp,asp,aspx,erb,ctp}"
216+
]
217+
},
218+
bower: {
219+
files: ['bower.json'],
220+
tasks: ['wiredep']
221+
},
222+
livereload: {
223+
options: {
224+
livereload: '<%= connect.options.livereload %>'
225+
},
226+
files: [
227+
'<%= config.dev %>/**/*.{html,php}',
228+
'.tmp/{,*/}*.css',
229+
'<%= config.dev %>/<%= config.img %>/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
230+
]
231+
}
232+
},
233+
// connect
234+
connect: {
235+
options: {
236+
port: 8080,
237+
hostname: 'localhost',
238+
livereload: true
239+
},
240+
livereload: {
241+
options: {
242+
middleware: function (connect) {
243+
return [
244+
modRewrite(['^[^\\.]*$ /index.html [L]']),
245+
serverStatic('.tmp'),
246+
connect().use(
247+
'/bower_components',
248+
serverStatic('./bower_components')
249+
),
250+
connect().use(
251+
'/app/assets/css',
252+
serverStatic('./app/assets')
253+
),
254+
serverStatic(LocalConfig.app)
255+
];
256+
}
257+
}
258+
},
259+
dist: {
260+
options: {
261+
base: 'public'
262+
}
263+
}
264+
},
265+
// wiredep
266+
wiredep: {
267+
task: {
268+
src: [
269+
'<%= config.dev %>/**/*.html', // .html support...
270+
'<%= config.dev %>/<%= config.sass %>/app.scss' // .scss & .sass support...
271+
],
272+
}
273+
},
274+
275+
removelogging: {
276+
dist: {
277+
src: ".tmp/concat/assets/js/app.min.js" // Each file will be overwritten with the output!
278+
}
279+
},
280+
281+
filehash: {
282+
options: {
283+
merge: true,
284+
keep: false,
285+
etag: "{{= +mtime}}",
286+
hashlen: "6"
287+
},
288+
css: {
289+
cwd: '<%= config.dist %>/assets',
290+
src: 'css/*.css',
291+
dest: '<%= config.dist %>/assets'
292+
},
293+
js: {
294+
cwd: '<%= config.dist %>/assets',
295+
src: 'js/*.js',
296+
dest: '<%= config.dist %>/assets'
297+
},
298+
}
299+
300+
};
301+
/*----------------
302+
INIT CONFIG
303+
-------------- -*/
304+
grunt.initConfig(APP);
305+
306+
// Task to generate the public files
307+
grunt.registerTask('build', [
308+
'clean',
309+
'wiredep',
310+
'useminPrepare',
311+
'compass:dist',
312+
'concat',
313+
'ngAnnotate',
314+
'removelogging',
315+
'uglify',
316+
'cssmin',
317+
'copy:dist',
318+
'htmlmin:dist',
319+
'filehash',
320+
'usemin',
321+
'imagemin:dist'
322+
]);
323+
324+
// Task for watching in development
325+
grunt.registerTask('serve', [
326+
'clean:tmp',
327+
'compass:dev',
328+
'connect:livereload',
329+
'wiredep',
330+
'watch'
331+
]);
332+
333+
};

0 commit comments

Comments
 (0)