简体   繁体   中英

Referencing a module / script when using npm and grunt

I'm looking into npm, grunt and bower, and I've made my first task which looks like this.

module.exports = function(grunt){

grunt.initConfig({
    concat: {
        options: {
            separator: ';',
        },
        dist: {
            src: ['node_modules/jquery/dist/jquery.js', 'node_modules/handlebars/dist/handlebars.js'],
            dest: 'dist/scripts.js',
        },
    },
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['concat']);

};

I was wondering if there's an easier/better way of adding the scripts. So that instead of typing the whole path you could just do src: [jquery, 'handlebars'],

and if bower is of any use regarding this?

Thank you.

I think this will help you.

https://github.com/gruntjs/grunt-contrib-concat#advanced-dynamic-filenames

You can configure common file directory path in package.json and use it in configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM