[New Version of PR #62] Correct order of files when concatenating custom Javascript files to custom.js in case custom Html templates are used. #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
this is a polished version of the pull request #62. The problem it addresses remains (see description below).
Preliminary Remarks:
Workflow of custom template creation
When custome Html templates are defined (either in external npm modules or as part of a template package, the
custom-html-templates
tasks creates the filecustomTemplates.js
in thejs
folder of the template package. It has the following contentsThis file has the following contents:
Subsequently, this file is concatenated by the
custom-js
task with all other Javascript files present in thejs
directory of the template package to a single Javascript file calledcustom.js
which is then saved also in the already mentionedjs
.The problem
(1) The
customTemplates.js
contains Javscript code that calls therun
method on an custom angular module referenced by the variableapp
.(2) In order for the Javascript code in the final concatenated
custom.js
file to work properly, the code contained in thecustomTemplates.js
file needs to be placed after the code contained in the file that is responsible for instantiating the angular module and assigning it to the variableapp
. Otherwise an error will be thrown.(3) Right now the code that instantiates the angular module and assigns it to the variable
app
is defined in a file calledmain.js
(At least that is my assumption). Given the fact that thecustom-js
tasks concatenates files in alphabetical order, the Javascript code in thecustomTemplates.js
file will be placed before the Javascript code in themain.js
file, causing an error to be throwing that signals that the variableapp
is not defined.The solutions
(1) Put the code that instantiates the custom angular module and binds it to the variable
app
in a file that in alphabetical order comes before the filecustomTemplates.js
. It is quite easy to do, however not very intiutive, since the aforementioned behaviour is nowhere clearly documented.(2) Provided, that the code which instantiates the custom angular module and binds it to the variable
app
is put in a file calledmain.js
, change the order of the files before they are concatenated.This pull request offers an implementation of solution 2 using
gulp-order
.Best regards, Matthias