frontend-maven-plugin

  • maven 실행시에 커맨드라인 실행으로 npm 및 관련 패키지를 자동으로 설치해주는 툴
  • 프론트엔드에서 개발과 환경 세팅을 하고, 빌드 요청은 maven 플러그인을 사용해 실행만 해주면 빌드시 자동으로 코드 생성

Installation

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>LATEST_VERSION</version>
    ...
</plugin>

Installing node and npm

<plugin>
    ...
    <execution>
        <id>install node and npm</id>
        <goals>
            <goal>install-node-and-npm</goal>
        </goals>
    </execution>
    <configuration>
        <nodeVersion>v6.11.3</nodeVersion>
        <npmVersion>5.4.1</npmVersion>
    </configuration>
</plugin>

install node modules

<plugin>
    <execution>
        <id>npm install</id>
        <goals>
            <goal>npm</goal>
        </goals>
    </execution>
    <configuration>
        <arguments>install</arguments>
    </configuration>
</plugin>

package.json build command

<execution>
    <id>npm run build</id>
    <goals>
        <goal>npm</goal>
    </goals>
    <configuration>
        <arguments>run build</arguments>
    </configuration>
</execution>

Optional Configuration

Working directory

package.json 파일이 존재하는 디렉토리를 지정

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <configuration>
        <workingDirectory>src/main/frontend</workingDirectory>
    </configuration>
</plugin>

Installation Directory

The installation directory is the folder where your node and npm are installed. You can set this property on the different goals. Or choose to set it for all the goals, in the maven configuration.

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>

    <!-- optional -->
    <configuration>
        <installDirectory>target</installDirectory>
    </configuration>    
</plugin>

results matching ""

    No results matching ""