首页 > 解决方案 > Grunt add @import path to js file

问题描述

my use case is the follwoing one: I need a general 'importer js' that only imports all files out of an dist. Ive tried it with several grunt task but found nothing that automatically build includes (only the import statement -> not the content) of paths of a dist to a js file. My last attempt was with

grunt-include-source

But as i assume it only can handle the import of js files to an html -> the follwoing attempt to change it from js to js was not succeed:

            includeSource: {
            options: {
                basePath: 'dist',
                baseUrl: 'dist/js',
                templates: {
                    js: {
                        js: '<script src="{filePath}"></script>',
                    }
                }
            },
            myTarget: {
                files: {
                    'dist/test.js': 'dist/templ.tpl.js'
                }
            }
        }

Does anyone have any other ideas - every suggestion is welcome! (Ive also tried with grunt-usemin or grunt-rev)

标签: javascriptgruntjsgrunt-usemin

解决方案


推荐阅读