-
Notifications
You must be signed in to change notification settings - Fork 30
/
Gruntfile.js
103 lines (98 loc) · 3.34 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
var endDefine = /}\);[\n\r\s]*\/\*[^*]*\*\//g;
//var rDefineSubmodule = /define\([""][^rv].*/;
var rDefineSubmodule = /define\([\s\S]*?{/;
var convertAmd = function (name, path, contents) {
if(rDefineSubmodule.exec(contents)) {
return contents
.replace(rDefineSubmodule, "var " + name + " = (function(){")
.replace(endDefine, "})();");
} else {
return contents.replace(/define\(([""][^""]+[""])\s*,.*/, "define($1, function(){");
}
};
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
copy: {
files: {
src: "dist/require-vuejs.js",
dest: "examples/require-vuejs.js"
}
},
jsmeter: {
all: {
files: {
src: ["src/plugin.js"]
},
options: {
dest: "report/",
files: {
src: ["src/plugin"]
}
}
}
},
eslint: {
options: {
configFile: ".eslintrc.js"
},
target: [
"./src/**/*.js",
"./spec/**/*.js"
]
},
jscpd: {
javascript: {
path: "src/",
exclude: []
}
},
requirejs: {
compile: {
options: {
baseUrl: "./src",
findNestedDependencies: true,
logLevel: 0,
name: "<%= pkg.name %>",
include: ["vue"], // needed to ensure that workds without need define paths
onBuildWrite: convertAmd,
optimize: "uglify",
wrap: {
start: "(function() {",
end: "})();"
},
out: "./dist/<%= pkg.name %>.min.js",
skipModuleInsertion: true,
skipSemiColonInsertion: true
}
}, // compile
dese: {
options: {
baseUrl: "./src",
useStrict: true,
name: "<%= pkg.name %>",
findNestedDependencies: true,
// Avoid inserting define() placeholder
skipModuleInsertion: true,
logLevel: 0,
// Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true,
include: ["vue"], // needed to ensure that workds without need define paths
wrap: {
start: "(function() {",
end: "})();"
},
optimize: "none",
onBuildWrite: convertAmd,
out: "./dist/<%= pkg.name %>.js"
}
} // dese
} // requirejs
});
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-requirejs");
grunt.loadNpmTasks("grunt-jsmeter");
grunt.loadNpmTasks("grunt-eslint");
grunt.loadNpmTasks("grunt-jscpd");
grunt.registerTask("default", ["eslint", "jscpd", "requirejs:compile", "requirejs:dese", "copy"]);
};