A
A
Artem2017-03-11 15:12:39
Angular
Artem, 2017-03-11 15:12:39

How to configure spring boot and maven to run webpack build script?

I want to set up an angular2 build to launch it when the spring starts, I have a WebMvcConfig and it has a
private void setLocationForStaticAssets(ConfigurableEmbeddedServletContainer container) {
File root;
String prefixPath = resolvePathPrefix();
root = new File(prefixPath + "target/www/");
if (root.exists() && root.isDirectory()) {
container.setDocumentRoot(root);
}
}
private String resolvePathPrefix() {
String fullExecutablePath = this.getClass().getResource("").getPath();
String rootPath = Paths.get(".").toUri().normalize().getPath();
String extractedPath = fullExecutablePath.replace(rootPath, "");
int extractionEndIndex = extractedPath.indexOf("target/");
if(extractionEndIndex <= 0) {
return "";
}
return extractedPath.substring(0, extractionEndIndex);
}
but if you do not run the npm run webpack:build script through the terminal, then of course there are no folders with the build angular)))
I want not to run it separately, but so that everything would be built from one button!
Also in pom I added:
plugin>
groupId>com.github.eirslett
artifactId>frontend-maven-plugin
version>${frontend-maven-plugin.version}
executions>
id>install node and npm
goals>
goal>install-node-and-npm
/goals>
configuration>
${node.version}
npmVersion>${npm.version}
/configuration>
/execution>
execution>
id>webpack build dev
goals>
goal>npm
/goals>
generate-resources
configuration>
arguments>run webpack:build
/configuration>
/execution>
/executions>
/plugin>
but it doesn't run!!!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question