-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
97 lines (81 loc) · 2.21 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
module.exports = function( grunt ) {
'use strict';
const fs = require( 'fs' ),
pkgInfo = grunt.file.readJSON( 'package.json' );
require( 'load-grunt-tasks' )( grunt );
// Project configuration
grunt.initConfig( {
pkg: pkgInfo,
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("dd-mm-yyyy") %> */',
checktextdomain: require( './.grunt-config/checktextdomain' ),
sass: require( './.grunt-config/sass' ),
postcss: require( './.grunt-config/postcss' ),
watch: require( './.grunt-config/watch' ),
bumpup: require( './.grunt-config/bumpup' ),
replace: require( './.grunt-config/replace' ),
release: require( './.grunt-config/release' ),
copy: require( './.grunt-config/copy' ),
clean: require( './.grunt-config/clean' ),
webpack: require( './.grunt-config/webpack' ),
karma: require( './.grunt-config/karma' ),
wp_readme_to_markdown: {
your_target: {
files: {
'README.md': 'readme.txt'
}
},
},
compress: {
build: {
options: {
mode: 'zip',
archive: './build/<%= pkg.name %>.zip'
},
expand: true,
cwd: 'build/<%= pkg.version %>/',
src: ['**/*'],
dest: '<%= pkg.name %>'
}
},
} );
// Default task(s).
grunt.registerTask( 'default', [
'i18n',
'scripts',
'styles',
] );
grunt.registerTask( 'i18n', [
'checktextdomain',
] );
grunt.registerTask( 'scripts', ( isDevMode = false ) => {
let taskName = 'webpack:production';
if ( isDevMode ) {
taskName = 'webpack:development';
}
grunt.task.run( taskName );
} );
grunt.registerTask( 'watch_scripts', () => {
grunt.task.run( 'webpack:development' );
} );
grunt.registerTask( 'styles', ( isDevMode = false ) => {
grunt.task.run( 'sass' );
if ( ! isDevMode ) {
grunt.task.run( 'postcss' );
}
} );
grunt.registerTask( 'watch_styles', () => {
grunt.task.run( 'watch:styles' );
} );
grunt.registerTask( 'build', [
'default',
'clean',
'copy',
'compress',
] );
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );
grunt.registerTask( 'qunit', [
'karma:unit',
] );
};