首页 > 解决方案 > 使用 Maven 可以实现角度延迟加载模块

问题描述

我正在使用 maven 多模块项目来创建 war 文件以集成 angular 和 spring-boot 应用程序。是否可以使用 maven 进行延迟加载功能模块块?这是我的前端 pom.xml:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.abc</groupId>
    <artifactId>ParentDashboard</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>Frontend</artifactId>

  <name>Frontend</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.3</version>
                <configuration>
                    <nodeVersion>v10.16.3</nodeVersion>
                    <npmVersion>6.9.0</npmVersion>
                    <workingDirectory>src/main/web/</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>npm install --production</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                    </execution>
                     <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prod</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run-script build</arguments>
                        </configuration>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我可以看到在 Visual Studio 代码中创建的块,但是使用这个 Maven 配置,我在 Eclipse 控制台中看不到块。有人能帮忙吗?

标签: javanode.jsangularmavenangular8

解决方案


似乎我已经使用 package.json 中的以下配置解决了它。

"build": "ng build --prod --aot --base-href=\"./\"".

现在我可以看到在 Eclipse 控制台中创建的单个模块块,并在 devTools 网络控制台中看到块。


推荐阅读