General developer forum

Grunt only one plugin (and not all moodle)

 
Picture of Valery Fremaux
Grunt only one plugin (and not all moodle)
Particularly helpful MoodlersPlugin developers

Hi guys,

is there a way to grunt localy one plugin for a local build without having to grunt all moodle ? the global grunt is quite long !!

 
Average of ratings: -
Picture of Sam Chaffee
Re: Grunt only one plugin (and not all moodle)
Core developersParticularly helpful Moodlers

Hi Valery,

If you are building AMD modules you can cd into the amd dir of your plugin and run grunt to build just the modules for that plugin. If you are building YUI modules you cd into the yui/src/whatever directory of your plugin and run grunt to build just that YUI module. I think similar options are available for compiling CSS, but I'm not as familiar with that.

https://docs.moodle.org/dev/Grunt

Hope that helps.

 
Average of ratings: Useful (1)
Picture of Valery Fremaux
Re: Grunt only one plugin (and not all moodle)
Particularly helpful MoodlersPlugin developers

That sounds good Sam,


as i am working daily on 170 plugins, i need to automate decently all the upstream pre-production chain and try to optimize compile time each time i change a coma in a script.

I'm going to try to implement and systematize local .js and .json files to see if this copes my needs.

 
Average of ratings: -
Picture of Valery Fremaux
Re: Grunt only one plugin (and not all moodle)
Particularly helpful MoodlersPlugin developers

Well, does not seem to work so straight :

without any action and cding to the module's root and running "grunt amd" is still running a global amd compilation.

What i did next :

I reinstalled grunt in the plugin's directory with a local package.json file containing the plugin name. This creates a new node_modules in the plugin you have to exclude from version system.

Now trying to run grunt in the plugin root still explores everything... and most ennoying are those third party plugins that do not fuly comply to verification rules... 

The essential purpose is to get those "build" min scripts compiled as they are now mandatory from 3.4 ahead.

 
Average of ratings: -
Picture of Paul Holden
Re: Grunt only one plugin (and not all moodle)
Core developersParticularly helpful MoodlersPlugin developers

without any action and cding to the module's root and running "grunt amd" is still running a global amd compilation.

You need to cd into the amd folder of your module root, i.e. dirroot/blocks/foo/amd before running grunt amd - this will compile only your plugins AMD source files

 
Average of ratings: Useful (1)
Picture of Valery Fremaux
Re: Grunt only one plugin (and not all moodle)
Particularly helpful MoodlersPlugin developers

tried that too, but seems still compiling scripts located in the theme...


This is finally dued to the system i am compiling with. Compîling on Windows needs the grun command to be explicted with the relaitve path this is shown in documentation as (just in the paragraph above plugin specifics)

"On Linux/Mac it will build everything in the current folder and below. On Windows, you need to specify the path on the command line like --root=admin/tool/templatelibrary "

and in fact, is a general rule.

Thanks to all
 
Average of ratings: -
Picture of Mark Sharp
Re: Grunt only one plugin (and not all moodle)
Core developersParticularly helpful MoodlersPlugin developers

Use grunt watch. It will then only work on the thing that's changed when you save the file.

 
Average of ratings: -