This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
executable file
·114 lines (102 loc) · 2.54 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
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const ArchivePlugin = require('webpack-archive-plugin');
module.exports = function(grunt) {
grunt.initConfig({
webpack: {
options: webpackConfig,
dev: { devtool: 'sourcemap' },
assets: {
plugins: webpackConfig.plugins.concat(
new ArchivePlugin({ output: 'dist', format: 'tar' })
)
},
prod: {
plugins: webpackConfig.plugins.concat(
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: 'production' } }),
new webpack.optimize.UglifyJsPlugin()
)
}
},
sync: {
assets: {
files: [
{
cwd: 'app/assets/sass',
src: '**',
dest: 'tmp/sass/'
},
{
cwd: 'app/assets/images',
src: '**',
dest: 'tmp/images/'
},
{
cwd: 'node_modules/govuk_template_mustache/assets/images',
src: '**',
dest: 'tmp/images/'
},
{
cwd: 'node_modules/govuk_frontend_toolkit/images',
src: '**',
dest: 'tmp/images/'
}
]
}
},
clean: ['tmp', 'public/images'],
// Watches assets and sass for changes
watch: {
css: {
files: ['app/assets/sass/**/*.scss'],
tasks: ['webpack:dev'],
options: { spawn: false }
},
assets: {
files: ['app/assets/**/*', '!app/assets/sass/**', '!app/assets/javascripts/**'],
tasks: ['webpack:dev'],
options: { spawn: false }
}
},
// nodemon watches for changes and restarts app
nodemon: {
dev: {
script: 'server.js',
options: {
nodeArgs: ['--trace-warnings', '--inspect'],
ext: 'js, json, yaml',
ignore: ['node_modules/**', 'app/assets/**', 'public/**'],
args: grunt.option.flags()
}
}
},
concurrent: {
dev: {
tasks: ['nodemon', 'watch'],
options: { logConcurrentOutput: true }
}
},
});
[
'grunt-contrib-clean',
'grunt-sync',
'grunt-contrib-watch',
'grunt-nodemon',
'grunt-concurrent',
'grunt-webpack'
].forEach(task => {
grunt.loadNpmTasks(task);
});
grunt.registerTask('setup-assets', ['webpack:assets']);
grunt.registerTask('setup-prod', [
'sync',
'webpack:prod',
'clean'
]);
grunt.registerTask('start-dev', [
'sync',
'webpack:dev',
'clean',
'concurrent:dev'
]);
};