Class JsPacker

    • Constructor Detail

      • JsPacker

        public JsPacker()
                 throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • processFileContent

        protected java.lang.String processFileContent​(java.lang.String relativeFilePath,
                                                      java.io.File file,
                                                      java.lang.String fileContent)
        Process Javascript files' content
        Specified by:
        processFileContent in class AbstractFilePacker
        Parameters:
        relativeFilePath - the relative path of the file being processed
        file - the file being processed
        fileContent - the fileContent as read by the AbstractFilePacker
        Returns:
        the processed file content, must not return null.
      • processPackContent

        protected java.lang.String processPackContent​(java.lang.String packContent)
        Process Javascript pack's content
        Specified by:
        processPackContent in class AbstractFilePacker
        Parameters:
        packContent - the whole pack content as computed by the AbstractFilePacker
        Returns:
        the processed pack content, must not return null.
      • perFileMinificationEnabled

        protected boolean perFileMinificationEnabled()
        Description copied from class: AbstractFilePacker
        Check if minification should be performed on each file as opposed to the whole pack.
        Specified by:
        perFileMinificationEnabled in class AbstractFilePacker
        Returns:
        true to use minified version of individual file, false if minification is disabled or enabled on whole pack
      • getLogger

        protected org.apache.log4j.Logger getLogger()
        Description copied from class: AbstractFilePacker
        Returns the logger to be used for log messages. This methods must be implemented by the file packer.
        Specified by:
        getLogger in class AbstractFilePacker
        Returns:
        Logger of this packer, must not return null.
      • minifyJS

        public static void minifyJS​(boolean force)
        Create a minified version of all JS found in JCMS.

        This method only process css file if minification is enabled through property "channel.js-packer.compressor.enabled".
        Only files contained in directories css, plugins and js are processed

        Parameters:
        force - set to true to force generation of minified file even if an up to date apparently exists
      • getJSFilesInPack

        public static java.util.Set<java.lang.String> getJSFilesInPack​(java.util.Collection<java.lang.String> jsFiles,
                                                                       java.lang.String browserName)
        Returns the set of the URLs created with the JS packer, respecting the constraints of the browser.
        Parameters:
        jsFiles - collection of JavaScript files to pack
        browserName - name of the browser used to find the properties 'channel.packer.xxx' defining the limit values. If null, use 'IE' because it's the most constraining.
        Returns:
        Set of the JS Packer URLs