-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
executable file
·197 lines (182 loc) · 7 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
module.exports = function (grunt)
{
'use strict';
// Load all Grunt tasks.
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Set up paths.
paths: {
src: {
sass: 'scss/',
js: 'js/',
templates: 'templates/'
},
dest: {
css: 'public/assets/css/',
js: 'public/assets/js/',
templates: 'public/templates/'
}
},
// Clean distribution and temporary directories to start afresh.
clean: [
'<%= paths.dest.css %>',
'<%= paths.dest.js %>'
],
// Run some tasks in parallel to speed up the build process.
concurrent: {
dist: [
'css',
'jshint',
'uglify'
]
},
// Check code quality of Gruntfile.js and site-specific JavaScript using JSHint.
jshint: {
options: {
bitwise: true,
camelcase: true,
curly: true,
eqeqeq: true,
es3: true,
forin: true,
immed: true,
indent: 4,
latedef: true,
noarg: true,
noempty: true,
nonew: true,
quotmark: 'single',
undef: true,
unused: true,
strict: true,
trailing: true,
browser: true,
globals: {
jQuery: false,
$: false,
module: true,
require: true
}
},
files: [
'Gruntfile.js',
'<%= paths.src.js %>**/*.js'
]
},
// Add vendor prefixed styles and other post-processing transformations.
postcss: {
options: {
processors: [
require('autoprefixer'),
require('cssnano')
]
},
files: {
expand: true,
cwd: '<%= paths.dest.css %>',
src: ['*.css'],
dest: '<%= paths.dest.css %>'
}
},
// Sass configuration.
sass: {
options: {
includePaths: [
'node_modules/foundation-sites/scss',
'node_modules/motion-ui/src'
],
outputStyle: 'expanded', // outputStyle = expanded, nested, compact or compressed.
sourceMap: false
},
dist: {
files: {
'<%= paths.dest.css %>app.min.css': '<%= paths.src.sass %>app.scss'
}
}
},
// Validate Sass files via sass-lint.
sasslint: {
options: {
configFile: '.sass-lint.yml'
},
target: [
'<%= paths.src.sass %>**/*.scss',
'!<%= paths.src.sass %>_settings.scss'
]
},
// Uglify and copy JavaScript files from `node_modules` plus `js/app.js` to `public/assets/js/`.
uglify: {
dist: {
files: [
{
'<%= paths.dest.js %>app.min.js': [
// Option 1: All Foundation JavaScript.
'node_modules/foundation-sites/dist/js/foundation.min.js',
// Option 2: Selective Foundation JavaScript.
//'node_modules/foundation-sites/dist/js/plugins*/*.min.js',
// Ignore JavaScript plugins that you do not require in your project, for example:
//'!foundation.abide.min.js',
//'!foundation.accordion.min.js',
//'!foundation.accordionMenu.min.js',
//'!foundation.drilldown.min.js',
//'!foundation.dropdown.min.js',
//'!foundation.dropdownMenu.min.js',
//'!foundation.equalizer.min.js',
//'!foundation.interchange.min.js',
//'!foundation.magellan.min.js',
//'!foundation.offcanvas.min.js',
//'!foundation.orbit.min.js',
//'!foundation.plugin.min.js',
//'!foundation.positionable.min.js',
//'!foundation.responsiveAccordionTabs.min.js',
//'!foundation.responsiveMenu.min.js',
//'!foundation.responsiveToggle.min.js',
//'!foundation.reveal.min.js',
//'!foundation.slider.min.js',
//'!foundation.smoothScroll.min.js',
//'!foundation.sticky.min.js',
//'!foundation.tabs.min.js',
//'!foundation.toggler.min.js',
//'!foundation.tooltip.min.js',
//'!foundation.util.box.min.js',
//'!foundation.util.core.min.js',
//'!foundation.util.imageLoader.min.js',
//'!foundation.util.keyboard.min.js',
//'!foundation.util.mediaQuery.min.js',
//'!foundation.util.motion.min.js',
//'!foundation.util.nest.min.js',
//'!foundation.util.timer.min.js',
//'!foundation.util.touch.min.js',
//'!foundation.util.triggers.min.js',
// Then add site-specific JavaScript at the end of file.
'<%= paths.src.js %>app.js'
]
// Site-specific vendor JavaScript libraries.
//, '<%= paths.dest.js %>vendor/example.min.js': ['node_modules/example/dist/example.js']
}
]
}
},
// Directories watched and tasks performed by invoking `grunt watch`.
watch: {
sass: {
files: '<%= paths.src.sass %>**/*.scss',
tasks: 'css'
},
js: {
files: '<%= paths.src.js %>**',
tasks: ['jshint', 'uglify']
},
templates: {
files: '<%= paths.src.templates %>**',
tasks: 'replace'
}
}
});
// Register tasks.
grunt.registerTask('build', ['clean', 'concurrent']);
grunt.registerTask('css', ['sasslint', 'sass', 'postcss']);
grunt.registerTask('default', ['watch']);
grunt.registerTask('travis', ['jshint', 'build']);
};