支持java工程打包前端代码为webjar包。官方地址: https://github.com/eirslett/frontend-maven-plugin

1. Node打包

1.1. Node版本

1.2. 配置示例

pom.xml
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- jar包前端资源存放地址配置-->
    <destUrl>${project.build.outputDirectory}/META-INFO/resources/webapp</destUrl>
    <!-- 前端工程工作区配置-->
    <workDirectory>frontend</workDirectory>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.9.1</version>
            <configuration>
                <nodeVersion>v13.9.0</nodeVersion>
                <workingDirectory>${workDirectory}</workingDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>install-npm</id>
                    <goals>
                        <goal>install-node-and-npm</goal>
                    </goals>
                </execution>
                <execution>
                    <id>npm-install</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                </execution>
                <execution>
                    <id>npm build</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>run-script build</arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

    <resources>
        <resource>
            <directory>${project.basedir}/${workDirectory}/dist</directory>
            <targetPath>${destUrl}</targetPath>
        </resource>
    </resources>
</build>