How to use the assetgraph.relations function in assetgraph

To help you get started, we’ve selected a few assetgraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assetgraph / assetgraph-builder / lib / transforms / postProcessCssImages.js View on Github external
imageInfo.incomingRelations.forEach(function (incomingRelation) {
                    var style = incomingRelation.cssRule.style;
                    style.removeProperty(postProcessPropertyName);
                    if (imageInfo.ie6) {
                        // Designates that the processed image should only be used in IE6
                        // Keep the original relation and use the underscore hack for getting
                        // IE6 to fetch the processed version:
                        if (('_' + incomingRelation.propertyName) in style) {
                            throw new Error("transforms.postProcessCssImages: Underscore hack already in use in Css rule");
                        }
                        style.setProperty('_' + incomingRelation.propertyName, 'url(...)', style.getPropertyPriority(incomingRelation.propertyName));
                        var relation = new AssetGraph.relations.CssImage({
                            propertyName: '_' + incomingRelation.propertyName,
                            cssRule: incomingRelation.cssRule,
                            from: incomingRelation.from,
                            to: processedAsset
                        });
                        assetGraph.addRelation(relation, 'after', incomingRelation);
                        relation.refreshHref();
                    } else {
                        // All browsers should see the processed version, replace the old relation:
                        var relation = new AssetGraph.relations.CssImage({
                            propertyName: incomingRelation.propertyName,
                            cssRule: incomingRelation.cssRule,
                            from: incomingRelation.from,
                            to: processedAsset
                        });
                        assetGraph.addRelation(relation, 'after', incomingRelation);

assetgraph

An auto discovery dependency graph based optimization framework for web pages and applications

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

56 / 100
Full package analysis

Similar packages