Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minifiedFile should in then same path with mergedFile #73

Closed
belerweb opened this issue Sep 15, 2014 · 5 comments
Closed

minifiedFile should in then same path with mergedFile #73

belerweb opened this issue Sep 15, 2014 · 5 comments
Assignees
Labels
Milestone

Comments

@belerweb
Copy link

I config jsFinalFile with "folder/app.js". I expect minifiedFile is "folder/app.min.js", but it's "app.min.js" in root dir.

@samaxes
Copy link
Owner

samaxes commented Sep 17, 2014

You can use the option jsTargetDir to change the target folder for your scripts.
More info: http://samaxes.github.io/minify-maven-plugin/minify-mojo.html

@samaxes samaxes closed this as completed Sep 17, 2014
@belerweb
Copy link
Author

That's not right. Let me explain more.

Assume I set jsTargetDir to "js". I config jsFinalFile to "folder/app.js", Then the app.js full path is"js/folder/app.js". But app.min.js full path is "js/app.min.js". I think it's should be "js/folder/app.min.js"

@belerweb
Copy link
Author

See the following code:

                if (skipMerge) {
                    log.info("Skipping the merge step...");
                    String sourceBasePath = sourceDir.getAbsolutePath();

                    for (File mergedFile : files) {
                        // Create folders to preserve sub-directory structure when only minifying
                        String originalPath = mergedFile.getAbsolutePath();
                        String subPath = originalPath.substring(sourceBasePath.length(),
                                originalPath.lastIndexOf(File.separator));
                        File targetPath = new File(targetDir.getAbsolutePath() + subPath);
                        targetPath.mkdirs();

                        File minifiedFile = new File(targetPath, (nosuffix) ? mergedFile.getName()
                                : FileUtils.basename(mergedFile.getName()) + suffix
                                        + FileUtils.getExtension(mergedFile.getName()));
                        minify(mergedFile, minifiedFile);
                    }
                } else if (skipMinify) {
                    File mergedFile = new File(targetDir, mergedFilename);
                    merge(mergedFile);
                    log.info("Skipping the minify step...");
                } else {
                    File mergedFile = new File(targetDir, (nosuffix) ? mergedFilename + TEMP_SUFFIX : mergedFilename);
                    merge(mergedFile);
                    File minifiedFile = new File(targetDir, (nosuffix) ? mergedFilename
                            : FileUtils.basename(mergedFilename) + suffix + FileUtils.getExtension(mergedFilename));
                    minify(mergedFile, minifiedFile);
                    if (nosuffix) {
                        if (!mergedFile.delete()) {
                            mergedFile.deleteOnExit();
                        }
                    }
                }

When skipMerge, you consider the subPath, but when skipMerge is false, you just put the minifiedFile in the targetDir, no consider about the subPath.

It's should be a bug.

@samaxes
Copy link
Owner

samaxes commented Sep 17, 2014

Yes, the minified file should be in the same folder as the merged file.
I need to take a closer look at this when I have some spare time.
Meanwhile feel free to submit a PR.

@samaxes samaxes reopened this Sep 17, 2014
@samaxes samaxes added bug and removed question labels Sep 17, 2014
@samaxes samaxes added this to the 1.7.5 milestone Sep 17, 2014
@samaxes samaxes self-assigned this Sep 17, 2014
@samaxes
Copy link
Owner

samaxes commented Oct 22, 2016

Fixed by the commit c9ca500.

@samaxes samaxes closed this as completed Oct 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants