vue.js - Gitlab CI / Pipelines 中忽略了 VueJS Webpack 别名
问题描述
我在<projectRoot>/vue.config.js
定义为:
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/app/'
: '/',
configureWebpack: {
resolve: {
alias: {
'@': 'C:\\Path\\To\\Project\\src'
}
}
}
}
这完美地允许我使用以下语法从其他组件导入 VueJS 组件:
<script>
import CheckboxInput from '@/components/inputs/CheckboxInput.vue'
...
</script>
但是,在我的 gitlab 管道中,我在阶段build:exec
步骤中收到以下错误build
:
$ yarn run build
yarn run v1.22.5
$ vue-cli-service build
- Building for production...
ERROR Failed to compile with 2 errors14:39:07
These dependencies were not found:
* @/components/collections/statistics/EmailStatisticsCollection.vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Dashboard.vue?vue&type=script&lang=js&
* @/components/collections/statistics/PrintStatisticsCollection.vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Dashboard.vue?vue&type=script&lang=js&
To install them, you can run: npm install --save @/components/collections/statistics/EmailStatisticsCollection.vue @/components/collections/statistics/PrintStatisticsCollection.vue
ERROR Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Job failed: exit status 1
我gitlab-ci.yml
的定义为:
stages:
- setup
- build
- test
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR\<..>\client
PIPELINE_UTILS_PATH: $CI_BUILDS_DIR\PipelineUtils
cache:
paths:
- node_modules/
- .env.local
before_script:
- Copy-Item $PIPELINE_UTILS_PATH\client.env $GIT_CLONE_PATH\.env.local
setup:install:
tags:
- vuejs
stage: setup
script:
- yarn install
build:lint:
tags:
- vuejs
stage: build
needs: ["setup:install"]
script:
- yarn run lint
build:exec:
tags:
- vuejs
stage: build
needs: ["setup:install"]
script:
- yarn run build
artifacts:
paths:
- dist
test:unit:
tags:
- vuejs
stage: test
needs: ["build:exec"]
script:
- yarn run test:unit
脚本在 package.json 中定义以使用 vue-cli-service:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
我在网上找不到任何东西,而且我更像是一个后端开发人员而不是前端,所以我有点超出我的深度。任何帮助表示赞赏!
谢谢
解决方案
推荐阅读
- python - IndexError:从for循环为元组分配值时列表索引超出范围
- azure - 将参数绑定到复杂对象的 Azure-Function eventthub 触发器问题
- json - 如何在 Spring Boot 中使用 JSON 数组创建过滤器
- jquery - 选中时隐藏复选框
- php - Windows 任务计划程序上次运行结果 0xff
- javascript - 在 JS 中生成 csv 并使用 ajax 请求 POST 将其发送到烧瓶
- c++ - 为什么clang-format在getter大括号之前不中断?
- java - JAXB内部实现接口com.sun.xml.bind.namespacePrefixMapper的Classloader问题
- sql-server - 与 sum 和小于的内连接
- javascript - 如何将 URL 的第一部分设置为 HTML 链接中的 JavaScript 变量