Coder Social home page Coder Social logo

dernasherbrezon / fingerprint-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 10.0 206 KB

Maven plugin for web resources optimization

Java 83.73% Shell 0.28% HTML 14.42% JavaScript 0.47% CSS 1.10%
html-minification java optimization nginx web jsp

fingerprint-maven-plugin's Issues

URL mapping

It would be great if there was a method of mapping URLs to the filesystem. For instance if my app has a prefix (like /apps) this plugin won't work by default because the URLs in the HTML won't line up with the file system structure. Something like the following could be useful:

<img src="/apps/app1/logo.png">

and my directory structure looks like this:

src/main/webapp/app1/logo.png

then set the following map in the pom.xml:

<urlMappings>
    <urlMapping>
        <urlPrefix>/apps/</urlPrefix>
        <fsPath>/</fsPath>
    </urlMapping>
</urlMappings>

The outcome would be a straightforward find/replace with the mappings. So /apps/app1/logo.png would map to /app1/logo.png on the file system.

Bug: hash of CSS file does not change when referenced image changes

Let's say your project consists of these files:

  • index.html references stylesheet.css
  • stylesheet.css references background.png
  • background.png

Running the plugin once works as expected:

  1. The image gets renamed according to its hash, and the reference to it in the CSS file is changed as well.
  2. The CSS file gets renamed according to its hash, and the reference to it in the HTML file is changed as well.

Now you replace/edit the image file and run the plugin again:

  1. The image gets renamed according to its new hash, and the reference to it in the CSS file is also changed.
  2. However, the CSS file is not renamed compared to the previous situation!

It turns out that the plugin uses the hashes of the original source file's contents. But we did not change the source CSS at all - it still references background.png!

The result is that in the HTML file, the reference to the CSS still has the same hash as before. Therefore, browsers will not reload the CSS, and will therefore not reload the image file!

This problem could be prevented if the plugin calculated the hashes of the modified files, i.e. after it altered the contained references to other resources.

Workaround: do not use any image URLs in CSS. ๐Ÿ˜ข

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.