Virmundi
Virmundi

Reputation: 2631

Yeoman + Grunt Disable Uglify

Background:

I'm working on a chrome extension. I used the yeoman generator. It worked like a charm. After I deployed the extension, I needed to debug a few issues.

Problem:

The code is uglified. I can't set break points. I can hardly read it. It is also optimized. This makes it hard to read as well. I would like to tell Grunt to skip uglifying the code.

Attempted Solutions:

  1. I tried to comment out the uglify task in the Grunt file. If I do this, not only is uglify not executed, but most of the scripts fail to copy into the "dist" directory.
  2. I can deploy the application from the "app" directory. If I do this, my human written code is loaded rather than the "dist" values. While this works, I wish to learn more about the inner workings of Grunt. It seems likely that there is some mechanism by which uglifying may be disabled while preserving copying.

Upvotes: 0

Views: 720

Answers (1)

Nelson Antunes
Nelson Antunes

Reputation: 161

It's the usemin task that supplies targets to the uglify task. When you comment out the uglify task usemin can't complete its flow (by default concat and uglify) and the scripts never get copied.

So you must configure the flow in useminPrepare options. Like this:

[...]
useminPrepare: {
    options: {
        stripBanners: true,
        dest: '<%= config.dist %>',
        flow: {
            steps: {
                js: ['concat'], css: ['concat', 'cssmin']
            },
            post: {}
        }
    },
[...]

This way you can remove the uglify task from the build sequence (you must, as it will complaint that have no targets and fail).

Documentation here: https://github.com/yeoman/grunt-usemin#flow

Upvotes: 1

Related Questions