Using a grunt browser in Gruntfile.js

I am having trouble finding an explanation of how to use grunt-browsify. Looking at the examples folder, I look under my node browser and see the following:

module.exports = function (grunt) { grunt.initConfig({ browserify: { vendor: { src: [], dest: 'public/vendor.js', options: { require: ['jquery'], alias: [ './lib/moments.js:momentWrapper', //can alias file names 'events:evt' //can alias modules ] } }, client: { src: ['client/**/*.js'], dest: 'public/app.js', options: { external: ['jquery', 'momentWrapper'], } } }, concat: { 'public/main.js': ['public/vendor.js', 'public/app.js'] } }); grunt.loadTasks('../../tasks'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.registerTask('default', ['browserify', 'concat']); }; 

What are the "provider" and "customer" and where are they registered? In the README file, they mention "preBundleCB", "dist", and I have seen quite a few others, and most of them have their own data structures. Are these options listed and explained anywhere?

+5
source share
1 answer

According to the Grunt configuration convention , the "provider" and "client" are targets . Their names are not defined using grunt or grunt-browsify. You can create as many goals as you want and give them the names you need. Each target has a files configuration, which is common to most Grunt tasks, such as src and dest , and an options configuration, which is a plugin. "dist" is another example of targets, and "preBundleCB" is a property of the grunt-browserify options.

You can individually invoke targets using grunt browserify:vendor and grunt browserify:client . And grunt browserify invokes all the goals of the browserify task, which are the "providers" and "clients" in this example.

Each grunt-browserify target creates an associated script file. In this example, the supplier target creates vendor.js , which contains jquery , moment.js named momentWrapper and events named evt . The target client creates app.js , which contains client/**/*.js and their dependencies, excluding jquery and momentWrapper .

+9
source

Source: https://habr.com/ru/post/1210135/


All Articles