-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
185 lines (170 loc) · 5.78 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
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: {
dir: 'src/',
sass: 'src/assets/sass/',
img: 'src/assets/img/'
},
docs: {
css: 'docs/assets/css/',
js: 'docs/assets/js/'
},
dest: { // Classic Yellow theme
dir: 'dist/classic/',
css: 'dist/classic/assets/css/',
img: 'dist/classic/assets/img/'
}
},
// Clean distribution and temporary directories to start afresh.
clean: [
'dist/',
'docs/assets/css/'
],
// Run some tasks in parallel to speed up the build process.
concurrent: {
dist: [
'css',
'jshint',
'replace',
'uglify'
]
},
// Copy files from `src/` to `dist/classic/assets/`.
copy: {
dist: {
files: [
{
expand: true,
cwd: '<%= paths.src.dir %>classic',
src: ['**', '!manifest.json'],
dest: '<%= paths.dest.dir %>',
filter: 'isFile'
},
{
expand: true,
cwd: '<%= paths.src.img %>',
src: '**',
dest: '<%= paths.dest.img %>'
},
{'<%= paths.dest.css %>custom-example.css': '<%= paths.src.sass %>custom-example.css'},
{'<%= paths.docs.js %>jquery.js': 'node_modules/jquery/dist/jquery.min.js'},
{'<%= paths.docs.js %>jquery-ui.js': 'node_modules/jquery-ui-dist/jquery-ui.min.js'}
]
}
},
// Check code quality of Gruntfile.js JavaScript using JSHint.
jshint: {
options: {
bitwise: true,
browser: true,
curly: true,
eqeqeq: true,
esversion: 6,
forin: true,
globals: {
module: true,
require: true
},
latedef: true,
noarg: true,
nonew: true,
strict: false,
undef: true,
unused: false
},
files: [
'Gruntfile.js'
]
},
// Add vendor prefixed styles and other post-processing transformations.
postcss: {
options: {
processors: [
require('autoprefixer'),
require('cssnano')
]
},
dist: {
files: [
{'<%= paths.dest.css %>textpattern.css': '<%= paths.dest.css %>textpattern.css'},
{'<%= paths.dest.css %>print.css': '<%= paths.dest.css %>print.css'},
{'<%= paths.docs.css %>design-patterns.css': '<%= paths.docs.css %>design-patterns.css'}
]
}
},
// Generate version number automatically in theme manifest.json file.
replace: {
theme: {
options: {
patterns: [
{
match: 'version',
replacement: '<%= pkg.version %>'
}
]
},
files: [
{'<%= paths.dest.dir %>manifest.json': '<%= paths.src.dir %>classic/manifest.json'}
]
}
},
// Sass configuration.
sass: {
options: {
implementation: require('sass'),
outputStyle: 'expanded', // outputStyle = expanded, nested, compact or compressed.
sourceMap: false
},
dist: {
files: [
{'<%= paths.dest.css %>textpattern.css': '<%= paths.src.sass %>default.scss'},
{'<%= paths.dest.css %>print.css': '<%= paths.src.sass %>print.scss'},
{'<%= paths.docs.css %>design-patterns.css': '<%= paths.src.sass %>design-patterns.scss'}
]
}
},
// Validate CSS files via stylelint.
stylelint: {
options: {
configFile: '.stylelintrc.yml'
},
src: ['<%= paths.src.sass %>**/*.{css,scss}']
},
// Uglify and copy JavaScript files from `node_modules`.
uglify: {
dist: {
// Preserve all comments that start with a bang (!) or include a closure compiler style.
options: {
output: {
comments: require('uglify-save-license')
}
},
files: [
{
'<%= paths.docs.js %>prism.js': [
'node_modules/prismjs/prism.js'
]
}
]
}
},
// Directories watched and tasks performed by invoking `grunt watch`.
watch: {
sass: {
files: '<%= paths.src.sass %>**/*.scss',
tasks: 'css'
}
}
});
// Register tasks.
grunt.registerTask('build', ['clean', 'concurrent', 'copy']);
grunt.registerTask('css', ['stylelint', 'sass', 'postcss']);
grunt.registerTask('default', ['watch']);
};