Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
grunt-monty-python
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d1fa039a
authored
2016-05-27 11:08:14 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add a path compressor to the requirejs output, so the filesystem
hierarchy.
1 parent
a78bd6c7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
bower.json
grunt-monty-python.js
package.json
bower.json
View file @
d1fa039
{
"name"
:
"grunt-monty-python"
,
"version"
:
"2016.05.27-
0
"
,
"version"
:
"2016.05.27-
1
"
,
"ignore"
:
[
"**/.*"
,
"node_modules"
,
...
...
grunt-monty-python.js
View file @
d1fa039
...
...
@@ -44,6 +44,20 @@ module.exports = function (grunt) {
});
grunt
.
registerTask
(
'fixRequireConfig'
,
function
fixRequireConfig
()
{
function
compressPaths
(
paths
,
result
)
{
var
prop
,
value
,
ptr
,
i
,
token
,
tokens
,
last
;
for
(
prop
in
paths
)
{
ptr
=
result
;
tokens
=
prop
.
split
(
'/'
);
last
=
tokens
.
pop
();
for
(
i
in
tokens
)
{
token
=
tokens
[
i
];
ptr
=
ptr
[
token
]
||
(
ptr
[
token
]
=
{});
}
ptr
[
last
]
=
paths
[
prop
].
replace
(
/^
(?:
.*
\/)?([
a-f0-9
]
+
)\.
.*$/
,
'$1'
);
}
return
result
;
}
var
config
=
grunt
.
config
(
'montyPython.config'
);
var
featureFlags
=
grunt
.
config
(
'montyPython.featureFlags'
);
var
segment
=
{},
segments
=
{};
...
...
@@ -75,7 +89,7 @@ module.exports = function (grunt) {
grunt
.
log
.
oklns
(
'map: '
+
id
+
' -> '
+
file
);
segment
[
id
]
=
file
;
});
segments
.
paths
=
segment
;
segments
.
paths
=
compressPaths
(
segment
,
{})
;
segment
=
{};
}
}
...
...
@@ -113,9 +127,22 @@ module.exports = function (grunt) {
if
(
notEmptyCount
)
{
lines
=
[
'(function(require, overlay) {'
,
' function expandPaths(paths, prefix, result) {'
,
' var prop, value;'
,
' for (prop in paths) {'
,
' value = paths[prop];'
,
' if (typeof value === "string") {'
,
' result[prefix + prop] = prefix + value + "." + prop;'
,
' } else {'
,
' expandPaths(value, prefix + prop + "/", result);'
,
' }'
,
' }'
,
' return result;'
,
' }'
,
' var prop, value, ptr, i, list, container;'
,
' for (prop in overlay) {'
,
' value = overlay[prop];'
,
' if (prop === "paths") value = expandPaths(value, "", {});'
,
' ptr = require;'
,
' list = prop.split(".");'
,
' for (i = 0; i < list.length; i++) {'
,
...
...
package.json
View file @
d1fa039
{
"name"
:
"grunt-monty-python"
,
"version"
:
"2016.05.27-
0
"
,
"version"
:
"2016.05.27-
1
"
,
"description"
:
"Build system for grunt"
,
"license"
:
"BSD"
,
"repository"
:
{
...
...
Please
register
or
sign in
to post a comment