-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
143 lines (129 loc) · 3.72 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
//
// == Installation ==
//
// Install all the packages required to build this:
// (Packages will be installed in ./node_modules - don't accidentally commit this)
// % yarn install
//
// == Building ==
//
// % yarn run grunt
//
// Watch for changes:
// % yarn run grunt watch
//
// Compress images (not done by the above tasks):
// % yarn run grunt img
//
module.exports = function (grunt) {
'use strict';
const sass = require('sass')
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['build'],
sass: {
options: {
implementation: sass,
outputStyle: 'compressed',
sourceMap: true,
includePaths: ['node_modules/'],
},
production: {
files: {
'build/main.min.css': 'assets/css/main.scss',
'build/admin.min.css': 'assets/css/admin.scss',
}
}
},
fingerprint: {
production: {
options: {
json: 'build/fingerprint.json',
},
src: [
'build/*.min.css',
'build/main.min.js'
],
},
},
uglify: {
dist: {
options: {
preserveComments: 'some',
compress: false,
sourceMap: 'build/main.min.js.map',
sourceMappingURL: 'main.min.js.map',
sourceMapRoot: '../',
},
files: {
'build/main.min.js': [
'assets/js/plugins/*.js',
'node_modules/es6-promise/dist/es6-promise.auto.js',
'node_modules/govuk-frontend/dist/govuk/all.js',
'assets/js/main.js',
'assets/js/comments.js',
'assets/js/buttons.js',
'assets/js/accordion.js'
],
},
},
},
copy: {
dist: {
files: [
{
src: [
'node_modules/bootstrap/img/glyphicons-halflings.png',
'node_modules/bootstrap/img/glyphicons-halflings-white.png',
'node_modules/govuk-frontend/dist/govuk/assets/fonts/*',
'node_modules/govuk-frontend/dist/govuk/assets/images/*',
'node_modules/govuk-frontend/dist/govuk/assets/manifest.json',
'node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js'
],
dest: 'build/',
},
{
expand: true,
cwd: 'assets/js/',
flatten: true,
src: 'govuk-frontend-load.js',
dest: 'build/'
}
],
},
},
image: {
dynamic: {
files: [{
expand: true,
cwd: 'assets/img',
src: ['**/*.{png,jpg,gif,svg}'],
dest: 'assets/img'
}]
}
},
_watch: {
files: ['assets/css/**/*.scss', 'assets/js/**/*.js'],
tasks: ['clean', 'copy', 'sass', 'uglify', 'fingerprint' ],
},
})
grunt.loadNpmTasks('grunt-sass')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-image')
grunt.loadNpmTasks('@dxw-digital/grunt-fingerprint')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.renameTask('watch', '_watch')
grunt.registerTask('watch', [
'default',
'_watch',
])
grunt.registerTask('default', [
'clean',
'copy',
'sass',
'uglify',
'fingerprint'
])
}