简体   繁体   中英

How to “npm pack” an angular library through Java/Spring boot application?

I have an angular project which has 5 common library made specific for our requirement. I am using com.github.eirslett maven plugin in my spring boot application to build all the libraries via pom.xml which then gets copied to dist/ folder. But I also want to pack those libraries because the path to those tarball (.tgz) file will be used in another application. As of now I have to go one by one into all 5 folders inside dist/ and run npm pack via cmd/terminal to create the library_name.tgz file. Is there a way to automate that just like building the libraries? The maven plugin mentioned above is used widely everywhere but it doesn't support npm pack command.

I figured it out.

In package.json

"build-lib-name": "ng build lib-name",
"pack-lib-name": "cd dist/lib-name && npm pack",
"lib-name": "npm run build-lib-name && npm run pack-lib-name"

and in pom.xml, under com.github.eirslett plugin, I added this execution

                <execution>
                    <id>lib-name</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <configuration>
                        <arguments>run lib-name</arguments>
                    </configuration>
                    <phase>generate-resources</phase>
                </execution>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM