Grunt only one plugin (and not all moodle)

Grunt only one plugin (and not all moodle)

by Valery Fremaux -
Number of replies: 7
Picture of Plugin 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: -
In reply to Valery Fremaux

Re: Grunt only one plugin (and not all moodle)

by Sam Chaffee -
Picture of Core developers

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)
In reply to Sam Chaffee

Re: Grunt only one plugin (and not all moodle)

by Valery Fremaux -
Picture of Plugin 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.

In reply to Sam Chaffee

Re: Grunt only one plugin (and not all moodle)

by Valery Fremaux -
Picture of Plugin 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.

In reply to Valery Fremaux

Re: Grunt only one plugin (and not all moodle)

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

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)
In reply to Paul Holden

Re: Grunt only one plugin (and not all moodle)

by Valery Fremaux -
Picture of Plugin 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: Useful (1)
In reply to Valery Fremaux

Re: Grunt only one plugin (and not all moodle)

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

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

Average of ratings: Useful (1)