简体   繁体   English

使用npm和grunt时引用模块/脚本

[英]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. 我正在研究npm,咕unt声和凉亭,并且已经完成了第一个任务,如下所示。

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'], 这样,您无需输入整个路径,而只需执行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 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. 您可以在package.json中配置公用文件目录路径,并在配置中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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