cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

Array src - writeto variable overwritten #32

Closed D1no closed 1 year ago

D1no commented 9 years ago

I want to collect all the javascript file references (paths) from all html files [src].

Is there a way to achieve this? Currently, the writeto variable jsRefs is getting overwritten and I am not sure how to get around this.

grunt.initConfig({
        dom_munger: {
            your_target: {
                options: {
                    read: {
                        selector: 'script',
                        attribute: 'src',
                        // Is there a way to instruct jsRefs to be
                        // a multi-dimensional array or object.key
                        // combination per source file holding
                        // the jsRefs Arrays?
                        writeto: 'jsRefs',
                        // <-
                        isPath: true
                    }
                },
                // Going through multiple html files, collecting javascript references
                src: ['html/*.html']
            },
        },
        log: {}
    });

    grunt.registerTask("log", function() {
        var jsFiles = grunt.config.process('<%= dom_munger.data.jsRefs %>');

        // only last processed file with array of paths
        console.dir(jsFiles);
    });