Skip to content

Commit 94bd379

Browse files
committed
minification and banners: grunt --> webpack
1 parent 7bb7416 commit 94bd379

File tree

4 files changed

+31
-55
lines changed

4 files changed

+31
-55
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
public
33
node_modules
44
temp
5-
/nbproject/private/
6-
local_development
5+
/nbproject/private/

Gruntfile.js

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@ module.exports = function (grunt) {
44
grunt.loadNpmTasks('grunt-contrib-connect');
55
grunt.loadNpmTasks('grunt-contrib-watch');
66
grunt.loadNpmTasks('grunt-contrib-jshint');
7-
grunt.loadNpmTasks('grunt-contrib-concat');
8-
grunt.loadNpmTasks('grunt-contrib-uglify');
7+
grunt.loadNpmTasks('grunt-contrib-copy');
98
grunt.loadNpmTasks('grunt-webpack');
109

1110
grunt.initConfig({
12-
packageBower: grunt.file.readJSON('./bower.json'),
13-
timestamp: (new Date()).toISOString(),
14-
releaseData: '/*!\n' +
15-
' * <%= packageBower.name %>\n' +
16-
' * <%= packageBower.homepage %>\n' +
17-
' * Version: <%= packageBower.version %> -- <%= timestamp %>\n' +
18-
' * License: <%= packageBower.license %>\n' +
19-
' */\n',
2011
connect: {
2112
app: {
2213
options: {
@@ -61,43 +52,11 @@ module.exports = function (grunt) {
6152
webpack: {
6253
dist: require("./webpack.config.js")
6354
},
64-
concat: {
65-
options: {
66-
banner: '<%= releaseData %> \n',
67-
footer: '',
68-
stripBanners: true,
69-
process: function (src, filepath) {
70-
var singleQuotes, strings;
71-
console.log("Processing " + filepath + " ...");
72-
strings = /("(?:(?:\\")|[^"])*")/g;
73-
singleQuotes = /'/g;
74-
return src.replace(strings, function (match) {
75-
var result;
76-
console.log("match: " + match);
77-
result = "'" + match.substring(1, match.length - 1).replace(singleQuotes, "\\'") + "'";
78-
console.log("replaced with: " + result);
79-
return result;
80-
});
81-
}
82-
},
83-
dynamic_mappings: {
84-
files: {
85-
'dist/ui-scroll.js': ['./temp/**/ui-scroll.js'],
86-
'dist/ui-scroll-grid.js': ['./temp/**/ui-scroll-grid.js'],
87-
'dist/ui-scroll-jqlite.js': ['./temp/**/ui-scroll-jqlite.js']
88-
}
89-
}
90-
},
91-
uglify: {
92-
options: {
93-
banner: '<%= releaseData %>'
94-
},
95-
common: {
96-
files: {
97-
'./dist/ui-scroll.min.js': ['./dist/ui-scroll.js'],
98-
'./dist/ui-scroll-grid.min.js': ['./dist/ui-scroll-grid.js'],
99-
'./dist/ui-scroll-jqlite.min.js': ['./dist/ui-scroll-jqlite.js']
100-
}
55+
copy: {
56+
sources: {
57+
files: [
58+
{expand: true, src: ['*'], cwd: 'temp', dest: 'dist/'},
59+
]
10160
}
10261
},
10362
jshint: {
@@ -167,16 +126,15 @@ module.exports = function (grunt) {
167126

168127
grunt.registerTask('buildWatcher', [
169128
'webpack',
170-
'concat'
129+
'copy:sources'
171130
]);
172131

173132
grunt.registerTask('build', [
174133
'jshint:test',
175134
'jshint:src',
176135
'webpack',
177136
'karma:travis',
178-
'concat',
179-
'uglify:common'
137+
'copy:sources'
180138
]);
181139

182140
grunt.registerTask('travis', [

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
"babelify": "^6.1.0",
3030
"express": "~3.4.8",
3131
"grunt": "~0.4.5",
32-
"grunt-contrib-concat": "~0.5.1",
3332
"grunt-contrib-connect": "~0.10.1",
33+
"grunt-contrib-copy": "^1.0.0",
3434
"grunt-contrib-jshint": "~1.0.0",
35-
"grunt-contrib-uglify": "0.9.1",
3635
"grunt-contrib-watch": "~0.6.1",
3736
"grunt-karma": "~0.12.0",
3837
"grunt-webpack": "^1.0.18",

webpack.config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
var path = require('path');
2+
var webpack = require('webpack');
3+
var packageJSON = require('./package.json');
4+
5+
var banner =
6+
packageJSON.name + '\n' +
7+
packageJSON.homepage + '\n' +
8+
'Version: ' + packageJSON.version + ' -- ' + (new Date()).toISOString() + '\n' +
9+
'License: ' + packageJSON.license;
10+
211
module.exports = {
312
entry: {
413
'ui-scroll': './src/ui-scroll.js',
@@ -21,5 +30,16 @@ module.exports = {
2130
}
2231
}
2332
]
24-
}
33+
},
34+
plugins: [
35+
new webpack.optimize.UglifyJsPlugin({
36+
compress: {
37+
warnings: true,
38+
},
39+
output: {
40+
comments: false,
41+
},
42+
}),
43+
new webpack.BannerPlugin(banner)
44+
]
2545
};

0 commit comments

Comments
 (0)