0

I have a Grunt file with the following content:

module.exports = function(grunt) {

//  require('load-grunt-tasks')(grunt);

  /* global process */

  // configures browsers to run test against
  // any of [ 'PhantomJS', 'Chrome', 'Firefox', 'IE']
  var TEST_BROWSERS = ((process.env.TEST_BROWSERS || '').replace(/^\s+|\s+$/, '') || 'PhantomJS').split(/\s*,\s*/g);


  // project configuration
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    config: {
      app: 'app',
      sources: 'lib',
      tests: 'test'
    },

    release: {
      options: {
        tagName: 'v<%= version %>',
        commitMessage: 'chore(project): release v<%= version %>',
        tagMessage: 'chore(project): tag v<%= version %>'
      }
    },
    browserify: {
      options: {
        browserifyOptions: {
          builtins: false
        },
        bundleOptions: {
          detectGlobals: false,
          insertGlobalVars: [],
          debug: true
        }
      },
      watch: {
        files: {
          '<%= config.app %>/bpmn-viewer.js': [ '<%= config.app %>/bpmn.js', 'index.js' ]
        },
        options: {
          watch: true
        }
      },
      standaloneViewer: {
        files: {
          '<%= config.app %>/bpmn-viewer.js': [ '<%= config.app %>/bpmn.js', 'index.js' ]
        },
        options: {
          alias: [
            'jquery:jquery',
            'lodash:lodash',
            'index.js:bpmn-js-diffing',
            '<%= config.app %>/bpmn.js:bpmn-js'
          ]
        }
      },
    },
    jsdoc: {
      dist: {
        src: [ '<%= config.sources %>/**/*.js' ],
        options: {
          destination: 'docs/api',
          plugins: [ 'plugins/markdown' ]
        }
      }
    }
  });

  // tasks

  grunt.registerTask('test', [ 'karma:single' ]);

  grunt.registerTask('auto-test', [ 'karma:unit' ]);

  // grunt.registerTask('default', [ 'jshint', 'test', 'browserify:standaloneViewer', 'jsdoc' ]);

  grunt.registerTask('default', [  ]);
};

I know that somewhere in this file there must be an expression that minifies the code (I inherited the code from someone else, therefore I don't know how it works). The resulting file is called bpmn-viewer.js.

Could the lines

      standaloneViewer: {
        files: {
          '<%= config.app %>/bpmn-viewer.js': [ '<%= config.app %>/bpmn.js', 'index.js' ]
        },

mean that the files '<%= config.app %>/bpmn.js', 'index.js' should be combinded to <%= config.app %>/bpmn-viewer.js?

If possible, please provide links to the documentation that describes it.

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325

1 Answers1

1

There is some information missing, like the project you forked off and the package.json dependencies.

Luckily, I found https://github.com/bpmn-io/bpmn-js-diffing and that's probably the project you forked. Lets note that this project is very old and so are its dependencies, which I had to fix for it to work, so the versioning alone might change my results from yours.

What I didn't find were minified contents. The file app/bpmn-viewer.js is the concatenation result. The multiple files are concat into this one, yes, but there's only the browserify header that is always minified within bpmn-viewer.js.

First off, you commented load-grunt-tasks and the "default" grunt task, so I'm not sure you really ran grunt of this Gruntfile.js. Commenting it out cannot work, because there are no calls to grunt.loadNpmTasks as far as I'm aware, grunt plugins are not loaded without any loading instruction.

Now to the documentation. You are right that the concatenation happens because of the files field. This is part of Grunts Task definition layout.

Browserify analyzes the given files and concats them into one. That's the abstract description, more of that in the browserify handbook.

Still keep in mind: The versions of your forked project are very old.

So here's what I could find out in short:

  • No, the contents are not minified
  • A browserify header (which are minified) and the source map contents are added to the final file

If you really have minified content, please provide the package.json dependencies and the real running Gruntfile.js.

Benno
  • 188
  • 5
  • Thanks for your answer. Regarding *If you really have minified content*: Let's figure out whether there are minified files or not. Is [this file](https://github.com/bpmn-io/bpmn-js-diffing/blob/master/app/bpmn-viewer.js) a minified one? I was told it was, but I'm no JavaScript expert. – Glory to Russia Sep 01 '20 at 15:36
  • 1
    Thanks for clarification. This is only a concatenated file with browserifies loading logic to make it work in the browser. I just now discovered this SO question: https://stackoverflow.com/questions/19694448/whats-the-difference-between-concat-and-uglify-and-minify So I was kinda wrong. There is concatenation (your file), minification and uglification. Read up on it over there! All other statements are true: The object at `standaloneViewer`is responsible for the concatenation. – Benno Sep 01 '20 at 16:54