Make the per module configuration options more consistent
mlegenhausen opened this issue · 5 comments
Currently there the global parameters space
, deps
, wrap
and coffee
which can be set al global configuration parameter and module specific. All are currently merged in module instead to be placed in the per module options.
Current per module configuration:
dist: {
space: ' ',
deps: [],
wrap: true,
coffee: true,
name: 'testmodule',
constants: {
...
}
}
How it should look like:
dist: {
options: {
space: ' ',
wrap: true,
coffee: true,
deps: [] // Don't know if this is the right location
},
name: 'testmodule',
constants: {
...
}
}
Cause this is an API change it will be released in 0.5.0.
Continuing discussion from #13.
The new syntax suggested above doesn't provide "Multiple Module Option". I have no idea if it's really necessary to support it, as there are other ways to achieve it - e.g. specify separate targets and then call each of them manually (e.g. instead of calling ngconstant:production
with multiple modules, one could call ngconstant:production/1
, ngconstant:production/2
and so on) or register a new single task that would call all these targets. If it's not necessary, I'd suggest to stick with the syntax suggested above.
On the other hand, if it's necessary to support multiple modules, maybe something like this could work (maybe even as the only available syntax):
ngconstant: {
options: {
space: ' ',
dest: '<%= yeoman.app %>/scripts/env-config.js',
wrap: '"use strict";\n\n <%= __ngModule %>',
name: 'envConfig',
},
development: {
modules: [{
constants: grunt.file.readJSON("config/development.json")
}]
},
production: {
modules: [{
constants: grunt.file.readJSON("config/production.json")
}]
}
}
Ok this gets more urgent cause verbose mode is broken for grunt-ng-constant
.
@szimek your configuration format seems to fit the grunt
configuration format. I will start working on this as soon as possible.
Ok I worked a little bit on this and I plan the following changes for the configuration
- Coffeescript support will be dropped. Instead use grunt-js2coffee
- Multi module support will be dropped. This simplifies the configuration and the task a lot. For all who need this, they can reconstruct it by using multiple targets with different
dest
,name
andconstants
options. dest
andname
will be added tooptions
constants
parameter now expect afunction
,string
orobject
. If it is astring
it must be a path to a json file. If it is a function it is first evaluated when the task runs, if this function returns a string it is also resolved to a json file.- New template delimiters added which does not conflict with the grunt ones.
The most simplest configuration now looks like:
ngconstant: {
options: {
dest: 'config.js',
name: 'configModule',
constants: {
package: grunt.file.readJSON('package.json')
}
},
build: {}
}
I have to try out if I can even remove the target.
Looks awesome. Is this already published?
Will be published today (if possible). Currently npm does not accept any publish of packages. You can already try out the master branch if you want.