Skip to content

Instantly share code, notes, and snippets.

@WallenHan
Last active July 12, 2019 01:45
Show Gist options
  • Save WallenHan/f91eaaf129915e643befa001bfd1c303 to your computer and use it in GitHub Desktop.
Save WallenHan/f91eaaf129915e643befa001bfd1c303 to your computer and use it in GitHub Desktop.
maven 打包 webpack 项目配置
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>npm i </id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<extensions>true</extensions>
<configuration>
<warSourceExcludes>
source/**,
package*.json,
test/**,
src/**,
assets/**,
node_modules/**,
.npmrc,
.gitignore,
*.html,
.eslintrc.json,
.eslintignore,
.babelrc,
webpack.*.js,
</warSourceExcludes>
<warSourceDirectory>${basedir}/src/main/webapp/</warSourceDirectory>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>WEB-INF/*</include>
</includes>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>${war.packagingExcludes}</packagingExcludes>
<archive>
<manifestEntries>
<WebContext-Name>/xxxxxx</WebContext-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment