thanpolas / grunt-closure-tools

Google Closure Tools for grunt
MIT License
95 stars 22 forks source link

Multiple dest files and error messages #60

Closed Globegitter closed 7 years ago

Globegitter commented 10 years ago

Using ember.js you need to minify multiple js files but also get them out as separate js files for it to work. Would it be somehow possible to add an option to have as many output files as input files? e.g.:

src: ['public/dist/scripts/components.js', 'public/dist/scripts/templates.js', 'public/dist/scripts/main.js'],
dest: ['public/dist/scripts/components.js', 'public/dist/scripts/templates.js', 'public/dist/scripts/main.js']

Also I noticed, that if I for example give it a wrong path for src or dest I don't get any error messages. It just blocks and I have to say it confused me for a while. So it would be really helpful if it could say something like: File does not exist.

Those two features would be really helpful. Especially the first one. Thanks for this great work so with this package btw.

thanpolas commented 10 years ago

have a look at this stackoverflow question and #45

Globegitter commented 10 years ago

Thank you @thanpolas. And in regards of leaving the naming the same, is that also possible? Or would I have to add something like .min.js?

thanpolas commented 10 years ago

that's up to you, check out Grunt docs http://gruntjs.com/configuring-tasks

Globegitter commented 10 years ago

Hmmm, I looked into it but I don't seem to get it to work the way I imagine it. Having:

expand: true,
src: ['public/dist/scripts/*.js'],
ext: '.min.js'

Works perfectly. But as soon as I remove the ext or change it to ext: '.js' it stops working.

thanpolas commented 10 years ago

Im not really sure if thats in this package's realm... which task are you using? paste your gruntconfig and the output, please add in the task's options debug: true

Globegitter commented 10 years ago

Oh, I am using your package:

closureCompiler:  {
            options: {
                compilerFile: 'compiler-latest/compiler.jar',
                checkModified: true,
                compilerOpts: {
                    compilation_level: 'SIMPLE_OPTIMIZATIONS',
                    externs: ['public/scripts/extern.js'],
                    define: ["'goog.DEBUG=false'"],
                    warning_level: 'verbose',
                    jscomp_off: ['checkTypes', 'fileoverviewTags'],
                    summary_detail_level: 3,
                    output_wrapper: '"(function(){%output%}).call(this);"'
                },
                execOpts: {
                    maxBuffer: 999999 * 1024
                }
            },
            dist: {
                expand: true,
                src: ['public/dist/scripts/*.js'],
                ext: '.min.js'
            }
        }

So having grunt-closure-tools configured like this works, though ideally I would just like for the same files to be overwritten. So if I have a components.js it now gets minified into components.min.js, but I would like for this package to just overwrite components.js. Does that make more sense now? should I still run it with debug: true?

Though it seems I just ran into a bigger problem, which might be out of your hands and bring this endeavor to a halt. I don't seem to be able to define some function-names that closure-compiler should not rename, such as require('handlebars'). Didn't find any practical solution on that.

thanpolas commented 10 years ago

you need to use a custom externs file.

Overwriting on sources is bad practice for Grunt, you need to add a few more steps to your build process that will rename and move files around so you get the result you want

skotchio commented 10 years ago

@thanpolas I don't agree with you. Overwriting on sources is not bad practice for Grunt because any people need have different build process like me. UglifyJS for example do this work fine https://github.com/gruntjs/grunt-contrib-uglify and I also want to see this feature in this module.

thanpolas commented 10 years ago

@vovan22 as you can see from the number of contributors in this repository, pull requests are welcome :)

Although, i am not sure that this is not already supported...

thanpolas commented 10 years ago

@Globegitter is it ok to close this issue? is there something todo here?

thanpolas commented 7 years ago

closing due to inactivity, feel free to re-open if the issue persists.