FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

Configuration parameter sources

Configuration parameter: sources

Package: fcf-framework-core

Available from version: 2.0.2

Type: object

An object that describes source files for loading JS modules on the client and server side

Description of the object structure:

The key is the name of the package. If the key is an empty string, then these are files from the application root

The value is an object with module loading rules. An object can have the following properties:

  • string webMain = "index.js" - The main JS file of the package, which will be loaded by the package name by the fcf.require function on the browser side.

  • object webFilePath = { "*": "@{{path}}@" } - An object that describes the rules for compiling paths to the downloaded file on the browser side

    Key - This is the file extension. If the key has the value "*", then this definition is used for all extensions.

    Value - This is a tokenized string containing the browser-side file path for all files in the module.

    The following variables are available in the tokenizer:

    • string path - Relative path in the package to the file

    • string directory - File directory

    • string shortName - Short filename without extension

    • string name - File name

    • string extension - File extension

    This option is used to generate the final file path.

    For example, to load a debug version of a JS file, with the debug flag enabled in the user context, you can use the following configuration:

    fcf.getConfiguration().append({ sources: { "PACKAGE_NAME": { webFilePath: { js: "@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(\".min.\") == -1 ? \".min\" : \"\"}}@.@{{extension}}@" } } });
  • object serverFilePath = { "*": "@{{path}}@" } - An object that describes the rules for compiling paths to the downloaded file on the server side.

    Key - This is the file extension. If the key has the value "*", then this definition is used for all extensions.

    Value - This is a tokenized string containing the browser-side file path for all files in the module.

    The following variables are available in the tokenizer:

    • string path - Relative path in the package to the file

    • string directory - File directory

    • string shortName - Short filename without extension

    • string name - File name

    • string extension - File extension

    This option is used to generate the final file path.

    For example, to load a debug version of a JS file, with the debug flag enabled in the user context, you can use the following configuration:

    fcf.getConfiguration().append({ sources: { "PACKAGE_NAME": { serverFilePath: { js: "@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(\".min.\") == -1 ? \".min\" : \"\"}}@.@{{extension}}@" } } });
  • object filePath = { "*": "@{{path}}@" } - An object that describes the rules for compiling paths to the downloaded file.

    Key - This is the file extension. If the key has the value "*", then this definition is used for all extensions.

    Value - This is a tokenized string containing the browser-side file path for all files in the module.

    The following variables are available in the tokenizer:

    • string path - Relative path in the package to the file

    • string directory - File directory

    • string shortName - Short filename without extension

    • string name - File name

    • string extension - File extension

    This option is used to generate the final file path.

    For example, to load a debug version of a JS file, with the debug flag enabled in the user context, you can use the following configuration:

    fcf.getConfiguration().append({ sources: { "PACKAGE_NAME": { filePath: { js: "@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(\".min.\") == -1 ? \".min\" : \"\"}}@.@{{extension}}@" } } });
  • string webPackagePath = fcf.getConfiguration().webModuleDirectory + "/" + MODULE_NAME - URI path to browser-side module directory defined for a specific module

  • object serverFiles - An object for describing the rules for loading individual files on the NODEJS server side.

    The key is the relative path to the file from the package directory.

    The value is the object of the module loading rules description.

    A value object can have the following fields:

    • string filePath - A tokenized string containing the browser-side file path for all files in the module.

      Overrides the package's webFilePath value for a specific file

      The following variables are available in the tokenizer:

      • string path - Full path to the file

      • string directory - File directory

      • string shortName - Short filename without extension

      • string name - File name

      • string extension - File extension

    • string result - A string containing the path to a variable containing the result of the JS module. This option is used to load modules declared without using the fcf.module function.

  • object webFiles - An object for describing the rules for downloading individual files on the browser side.

    The key is the relative path to the file from the package directory.

    The value is the object of the module loading rules description.

    A value object can have the following fields:

    • string filePath - A tokenized string containing the browser-side file path for all files in the module.

      Overrides the package's webFilePath value for a specific file

      The following variables are available in the tokenizer:

      • string path - Full path to the file

      • string directory - File directory

      • string shortName - Short filename without extension

      • string name - File name

      • string extension - File extension

    • string result - A string containing the path to a variable containing the result of the JS module. This option is used to load modules declared without using the fcf.module function.

    • string loadState - If the parameter is defined, then the first time the JS model is loaded in the tokenized string, the condition is first determined, and if the result of the calculated string returns true, then the module is considered already loaded and the result is returned by the "result" parameter. This method allows you to load JS modules not declared by the fcf.module function together using the script tag and the fcf.require method (that is, to avoid double loading the module).

      fcf.getConfiguration().append({ sources: { "jquery": { webMain: "jquery.js", webFilePath: { js: "@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(\".min.\") == -1 ? \".min\" : \"\"}}@.@{{extension}}@" }, webFiles: { "jquery.js": { result: "jQuery", loadState "@{{!!window.jQuery}}@", } } }, } });

  • object files - An object for describing the rules for downloading individual files on the browser side and on the server side.

    The key is the relative path to the file from the package directory.

    The value is the object of the module loading rules description.

    A value object can have the following fields:

    • string filePath - A tokenized string containing the browser-side file path for all files in the module.

      Overrides the package's webFilePath value for a specific file

      The following variables are available in the tokenizer:

      • string path - Full path to the file

      • string directory - File directory

      • string shortName - Короткое имя файла без расширения

      • string name - File name

      • string extension - File extension

    • string result - A string containing the path to a variable containing the result of the JS module. This option is used to load modules declared without using the fcf.module function.

    • string loadState - If the parameter is defined, then the first time the JS model is loaded in the tokenized string, the condition is first determined, and if the result of the calculated string returns true, then the module is considered already loaded and the result is returned by the "result" parameter. This method allows you to load JS modules not declared by the fcf.module function together using the script tag and the fcf.require method (that is, to avoid double loading the module). The parameter is applied only on the browser side.

      fcf.getConfiguration().append({ sources: { "jquery": { webMain: "jquery.js", webFilePath: { js: "@{{directory}}@/@{{shortName}}@@{{!fcf.getContext().debug && name.indexOf(\".min.\") == -1 ? \".min\" : \"\"}}@.@{{extension}}@" }, files: { "jquery.js": { result: "jQuery", loadState "@{{!!window.jQuery}}@", } } }, } });