An open API service indexing awesome lists of open source software.

https://github.com/maasdi/react-assets-maven-plugin

This Maven plugin help you sync view template (JSP, FreeMarker, Thymeleaf) and react build assets during build process.
https://github.com/maasdi/react-assets-maven-plugin

java maven maven-plugin react react-assets react-assets-maven-plugin react-scripts reactjs spring spring-boot

Last synced: 5 months ago
JSON representation

This Maven plugin help you sync view template (JSP, FreeMarker, Thymeleaf) and react build assets during build process.

Awesome Lists containing this project

README

          

React Assets Maven Plugin
=======================
[![Build Status](https://travis-ci.org/maasdi/react-assets-maven-plugin.svg?branch=master)](https://travis-ci.org/maasdi/react-assets-maven-plugin/builds)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.maasdi/react-assets-maven-plugin/badge.svg?style=flat&logo=appveyor)](https://maven-badges.herokuapp.com/maven-central/com.github.maasdi/react-assets-maven-plugin)

This Maven plugin help you sync view template (JSP, FreeMarker, Thymeleaf) and react build assets during build process.

## Objectives
Build React + Spring application with server rendering view sometimes very messy,
because `npm run build` generate files with hash, every time code change the hash will change.

Often we come up with workaround by renaming the files to static file name,
but this can easily break code splitting and lose potential advantages for production [read here](https://create-react-app.dev/docs/production-build/).

This plugin will let you sync those assets and your server rendered view during maven `process-resources` phase.

## Requirements
* Maven 3 and Java 1.8

## Usage
Given that you have template `/src/main/resources/templates/app.ftlh`

```html






Test Server Render HTML



You need to enable JavaScript to run this app.




```

Then

```xml

com.github.maasdi
react-assets-maven-plugin
1.0.1


sync-assets-template
process-resources

${project.basedir}/frontend/build


${project.basedir}/src/main/resources/templates/app.ftlh
${project.basedir}/target/classes/templates




process-asset


```

## Options
* `assetsDirectory` - The react assets directory, this directory should be react build folder or folder with similar structure.
* `resources` - The list of resource to process, possibly JSP, FreeMarker template or Thymeleaf file.
* `manifestName` - The react manifest file name, default value is `asset-manifest.json`.
* `cssMarkup` - The CSS markup that will be replace (case sensitive). default value is ``.
* `jsMarkup` - The Javascript markup that will be replace (case sensitive). default value is ``.
* `runtimeMarkup` - The main-runtime markup that will be replace (case sensitive). default value is ``.
* `publicUrl` - The react asset `PUBLIC_URL`, default value is `/`
* `inlineRuntimeChunk` - By default runtime-asset will be embed, set this parameter to `false` which will load chunk instead of embedding it in your view.

## Sample

There is sample of Spring Boot + React [here](https://github.com/maasdi/react-assets-maven-plugin-sample)

## Licenses:
* Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0