-
Notifications
You must be signed in to change notification settings - Fork 6
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
Substituting <script> tags in HTML with merged values #4
Comments
Comment by vgalcenco +1 for this feature to be implemented as I'm facing exactly the same challenges Andrea mentioned, however in my scenario I don't have a single page app. |
Comment by stefan-niedermann +1 from me, too. i like the plugin but if i use it, my complete project depends on maven because i have to link a script file which does not exist until maven creates it. |
Comment by woodgoblin +1 also. |
vote +1 |
Is there still any interest in this? I could imagine the following approach, what do you think? For each execution, add a configuration to the plugin for the HTML and for selecting a script tag in the file, e.g. by ID. The plugin would then replace the <!-- Configure resources so that target/generated-resources/frontend/js -->
<!-- is copied to target/classes -->
<configuration>
<htmlRoot>src/main/resources/webapp</htmlRoot>
<scriptRoot>target/generated-resources/frontend/js</scriptRoot>
<baseTargetDir>target/generated-resources/frontend/js</baseTargetDir>
</configuration>
<executions>
<execution>
<configuration>
<targetDir>public/resources/main</targetDir>
<outputFilename>script.min.js</outputFilename>
<htmlOutput>
<htmlFile>src/main/resources/webapp/public/pages/profile/index.html</htmlFile>
<scriptId>main</scriptId>
</htmlOutput>
<configuration>
</execution>
<execution>
<configuration>
<targetDir>public/resources/special/other</targetDir>
<outputFilename>script.min.js</outputFilename>
<htmlOutput>
<htmlFile>src/main/resources/webapp/public/pages/sub/dashboard/index.html</htmlFile>
<scriptId>other</scriptId>
</htmlOutput>
<configuration>
</execution>
</executions> This will create 2 minified files
These files are put in
<html>
<body>
<script id="main"></script>
</body>
</html> The The path of The path of Therefore, the path <html>
<body>
<script id="main" src="../../resources/main/script.min.js"></script>
</body>
</html> Similarly, for the second script file, the HTML file becomes: <html>
<body>
<script id="other" src="../../../resources/special/other/script.min.js"></script>
</body>
</html> When no |
Thanks @blutorange for following this up! To share my 2 cents.
And after the build, we expect it help me automatically update the html into
Above design will satisfy this use case good. It is also a wise idea to leverage the script id to locate to the right <script> element - it would satisfy the case when we have 3rd party <script> elements in same HTML file. However, this design of configuration might worthy second consideration when we wanted to deal with use case as below :), I would say it can be a relevant rare case, perhaps we can consider that later on.
|
You can try out version 2.32.0-SNAPSHOT if you'd like. See the site for documentation on the new options, as well as the JavaDocs for HtmlUpdate and the Mojo goal docs. Let me know what you think -- I can still change some settings if it helps.
I'm not quite sure what your setup is, but the configuration should be flexible enough to achieve this -- you can use multiple executions, multiple |
Any opinions on the pre-release snapsoht, @grantsunny ? |
Thank you @blutorange - recently were coupled by several other things, will try this week or next week and back to here. I appreciate your great effort man! |
Issue by Adhara3
Friday Feb 20, 2015 at 15:41 GMT
Originally opened as samaxes#88
I thing this plugin does a great job but this feature is, IMHO, missing and makes the merge feature less usable.
I saw that you created the bundle feature in 1.7.5 (great!) and that could be the starting point to substitute in the HTML files the old css/js script/link tags with the new ones.
In my scenario I have a single page app with only one HTML containing all the imports. I am using Angular JS which is best managed with several js files (50+).
It would be great to bundle all of them into a single file and change the script tag so that I only import that single file. That would improve performances a lot!
It is a nice to have, but nothing really critical since, while the HTTP request for 50+ files may be not ideal, for single page apps this is performed only once.
Thanks
Andrea
The text was updated successfully, but these errors were encountered: