gradle-js-plugin
gradle-js-plugin copied to clipboard
Is RequireJS `include: [... list of files, not just one file...]` supported?
This works fine for me:
requireJs {
source = ...
dest = ...
requirejs.options = [
baseUrl: ...
name: ...
paths: [
requireLib: "External/require",
],
include: 'External/require',
optimize: 'none'
]
}
But this fails: (the only difference is the include:
part)
requireJs {
source = ...
dest = ...
requirejs.options = [
baseUrl: ...
name: ...
paths: [
requireLib: "External/require",
],
include: [ <-- an array causes an error
'External/require',
'Some/File',
'Another/File'
],
optimize: 'none'
]
}
With this weird error: (note the [
)
java.io.FileNotFoundException: /data/dev/cms-components/resources/js/[External/require.js (No such file or directory)
I'm getting the impression that include:
only works with one single file, and that Gradle attempts to convert the array to a string, hence the [
. Am I correct that include
only works with one file?
((Listing many files is supported with the pure Javascript "version" of RequireJS.))
I too faced this issue. requireJs gradle task is not handling the conversion from options map to command line arguments properly
I picked this code from GradleJSTask
options.each() { key, value -> logger.debug("${key} == ${options[value]}") def keyAlreadyAdded = (key.equalsIgnoreCase("out") && dest) || (key.equalsIgnoreCase("dir") && destDir) if (!keyAlreadyAdded) { args.add("${key}=${value}") } }
the above code is not handling the array input properly. it should convert the array input to something like this "include=requireLib, anothermodule"
there are other limitations in command line syntax. this is found on requirejs.org There is a limitation on the command line argument syntax. Dots are viewed as object property separators, to allow something like paths.jquery=lib/jquery to be transformed to the following in the optimizer: paths: { jquery: 'lib/jquery' }
Hence, i preferred to use requirejs.buildProfile options instead of requirejs.options
please refer this link for more information https://github.com/jrburke/requirejs/issues/369#issuecomment-19286803
Hi,
I am trying gradle js plugin for requireJS but it failing.
build.gradle:
requireJs { source = javascript.source.dev.js.files dest = file("${buildDir}/portal-all.js") requirejs.buildprofile = new File("tools/build.js")
}
And my build.js :
({ appDir: '../WebRoot', dir: '../build', mainConfigFile: '../WebRoot/application/main.js', optimizeCss: 'none', optimize: 'none', fileExclusionRegExp: /WEB-INF|META-INF|assets|doc|nodejs|bootstrap-sass/, modules: [ //First set up the common build layer. { //module names are relative to baseUrl name: 'application/main', excludeShallow: ['angular', 'angular-resource', 'kendo.directives'
]
}
]
})
Error:
:portal:requireJs Error: Error: Missing either a "name", "include" or "modules" option :portal:requireJs FAILED
FAILURE: Build failed with an exception.
Any help would be appreciated.
Thanks, Parthi