-
Notifications
You must be signed in to change notification settings - Fork 18
/
Gruntfile.js
executable file
·127 lines (112 loc) · 3.03 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
/*!
* USkin's Gruntfile
* Author: Lee Yao <[email protected]>
* Licensed under MIT
*/
var fs = require('fs');
var webpackConfig = require('./webpack.config.js');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * USkin v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Inspired by bootstrap\n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license %> (https://github.com/icecreamliker/uskin/blob/master/LICENSE)\n' +
' */\n',
// Task configuration.
clean: {
dist: ['dist'],
legacy: ['dist/js/fonts', 'dist/js/css.js', 'dist/js/css.js.map', 'dist/js/*.css.min.js']
},
webpack: {
options: webpackConfig,
dev: {
output: {
filename: '[name].js'
},
plugins: [
new ExtractTextPlugin({
filename: '../css/uskin.css'
})
],
devtool: 'source-map'
},
build: {
plugins: [
new ExtractTextPlugin({
filename: '../css/[hash:6].uskin.min.css'
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]
}
},
webfont: {
icons: {
src: 'fonts_svg/*.svg',
dest: 'css/fonts',
options: {
types: 'eot,woff,ttf,svg',
syntax: 'bem',
stylesheet: 'less',
relativeFontPath: 'fonts',
destHtml: 'docs/raw_demos',
templateOptions: {
baseClass: 'glyphicon',
classPrefix: 'icon-'
},
callback: function() {
var src = 'css/fonts/icons.less',
dest = 'css/icons.less';
fs.renameSync(src, dest);
}
}
}
},
copy: {
fonts: {
expand: true,
cwd: './dist/js',
src: 'fonts/*',
dest: './dist/css'
},
img: {
expand: true,
cwd: './dist/js',
src: 'img/*',
dest: './dist/css'
}
},
usebanner: {
options: {
position: 'top',
banner: '<%= banner %>'
},
files: {
src: ['dist/css/*.css', 'dist/js/*.js']
}
}
});
// These plugins provide necessary tasks.
require('load-grunt-tasks')(grunt, {
scope: 'devDependencies'
});
require('time-grunt')(grunt);
// Build JS
grunt.registerTask('js', ['webpack:dev', 'webpack:build']);
// Default task.
grunt.registerTask('build', ['clean:dist', 'js', 'copy', 'clean:legacy', 'usebanner']);
// Release with hash.
grunt.registerTask('release', ['clean:dist', 'webpack:build', 'copy', 'clean:legacy', 'usebanner']);
// Generate web font
grunt.registerTask('font', ['webfont']);
};