更改vuejs项目中网页包的dist/文件夹的目标(使用前端maven插件)?
我正在使用前端maven插件构建使用webpack的vuejs前端 由于我使用的是maven,所有生成/构建的资源通常都会写入更改vuejs项目中网页包的dist/文件夹的目标(使用前端maven插件)?,maven,webpack,Maven,Webpack,我正在使用前端maven插件构建使用webpack的vuejs前端 由于我使用的是maven,所有生成/构建的资源通常都会写入target/文件夹,我在.gitnore上也有这个文件夹 但是开箱即用的网页包在我的项目根目录中创建dist/文件夹。我宁愿把它放在myfrontend/target/文件夹中 我没有找到任何关于如何更改dist/文件夹位置的文档,或者这是否是一个坏主意-例如,如果更改位置,它是否会打破惯例并带来许多其他问题 但是,我确实尝试修改了index.js文件,如下所示,似乎可
target/
文件夹,我在.gitnore
上也有这个文件夹
但是开箱即用的网页包在我的项目根目录中创建dist/
文件夹。我宁愿把它放在myfrontend/target/
文件夹中
我没有找到任何关于如何更改dist/
文件夹位置的文档,或者这是否是一个坏主意-例如,如果更改位置,它是否会打破惯例并带来许多其他问题
但是,我确实尝试修改了index.js文件,如下所示,似乎可以完成这项工作:
myfrontend/config/index.js
build: {
// Template for index.html
//index: path.resolve(__dirname, '../dist/index.html'),
index: path.resolve(__dirname, '../target/dist/index.html'),
// Paths
//assetsRoot: path.resolve(__dirname, '../dist'),
assetsRoot: path.resolve(__dirname, '../target/dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
但由于我没有找到任何教程或文档来描述如何做到这一点,我有一种感觉,我可能走错了路
或者像这样定制网页包是完全有效的方法,我是通过index.js文件中的正确配置来实现的(例如,我没有找到从前端maven插件中控制dist/文件夹位置的方法)
更新:
我在文件中找到了这个重新配置dist/
文件夹路径的项目:
但是,如果我尝试将该文件添加到项目的根目录中,它仍然使用在中指定的配置:myfrontend/config/index.js
那么,如何使我的项目与vue.config.js文件兼容,而不是对index.js文件进行黑客攻击呢 我要做的是向我的package.json添加另一个脚本
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build ",
"build-move-to-target": "ng build && mv dist/ path/to/target/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
我使用build move to target作为脚本,将我的dist/文件夹内容移动到我的目标文件夹
下面是我的pom.xml文件配置
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.8.0</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>package</phase>
<configuration>
<installDirectory>target/</installDirectory>
<nodeVersion>v12.13.1</nodeVersion>
<yarnVersion>v1.19.1</yarnVersion>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>package</phase>
<configuration>
<installDirectory>target/</installDirectory>
<arguments>build-move-to-target</arguments>
<workingDirectory>path/to/frontend/</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
com.github.eirslett
前端maven插件
1.8.0
安装节点和纱线
安装节点和纱线
包裹
目标/
v12.13.1
v1.19.1
纱线安装
纱线
包裹
目标/
构建移动到目标
路径/到/前端/
我要做的是向我的package.json中添加另一个脚本
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build ",
"build-move-to-target": "ng build && mv dist/ path/to/target/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
我使用build move to target作为脚本,将我的dist/文件夹内容移动到我的目标文件夹
下面是我的pom.xml文件配置
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.8.0</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>package</phase>
<configuration>
<installDirectory>target/</installDirectory>
<nodeVersion>v12.13.1</nodeVersion>
<yarnVersion>v1.19.1</yarnVersion>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>package</phase>
<configuration>
<installDirectory>target/</installDirectory>
<arguments>build-move-to-target</arguments>
<workingDirectory>path/to/frontend/</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
com.github.eirslett
前端maven插件
1.8.0
安装节点和纱线
安装节点和纱线
包裹
目标/
v12.13.1
v1.19.1
纱线安装
纱线
包裹
目标/
构建移动到目标
路径/到/前端/
Ok是否有任何原因比在index.js文件中配置好?Ok是否有任何原因比在index.js文件中配置好?