1 | Mincer = require "mincer"
|
2 |
|
3 | module.exports = class RequireEngine extends Mincer.Template
|
4 |
|
5 | @defaultMimeType: "application/javascript"
|
6 |
|
7 | constructor: () ->
|
8 | super
|
9 |
|
10 | evaluate: (context) ->
|
11 | define = "define"
|
12 | name = context.logicalPath
|
13 | data = this.data
|
14 | index = data.indexOf(define)
|
15 | if index != -1
|
16 | before = data.substr(0, index)
|
17 | data = data.substr(index)
|
18 | data = data.substr(define.length)
|
19 | data = data.trimLeft()
|
20 | data = data.substr(1)
|
21 | data = before + define + "(\"#{name}\", " + data
|
22 | this.data = data
|
23 |
|